❔ Help with Lists/Combobox
public partial class Form1 : Form
{
const decimal SALES_TAX_RATE = 0.15m;
// private List<Order> orders = new List<Order>(){"Potatos"};
// string[] genres = { "Blues", "Country", "Hip Hop", "Easy Listening", "Rock", "Pop" };
// List<Order> order = new List<Order>(genres);
string[] genres = { "Blues", "Country", "Hip Hop", "Easy Listening", "Rock", "Pop" };
List<Order> orders = new List<Order>();
public Form1()
{
InitializeComponent();
}
//string[] genres = new string[]
// {
// "Blues",
// "Country",
// "Easy Listening",
/// "Hip Hop",
// "Rock",
// "Pop"
// };
#region Methods
private void ResetForm()
{
cboGenres.SelectedIndex = -1;
txtAlbumName.Text = "";
txtArtistName.Text = "";
txtQuantity.Text = "";
txtPrice.Text = "";
txtArtistName.Focus();
}
public void LoadGenres()
{
for (int i = 0; i < genres.Length; i++)
{
cboGenres.Items.Add(genres[i]);
}
}
private void Form1_Load(object sender, EventArgs e)
{
LoadGenres();
}
27 Replies
for some reason, the list wont show up in my combobox
theres no actual errors in the code and it does run, so im not sure what it is
$codegif
and please remove the commented out duplicate code, it just makes reading really hard
at a glance, it seems okay. Are you sure the
Form1_Load
event is firing? use the debugger to make sureok ill try, also maybe its cause i havent got to a certain part of assignment yet where i have to do something else to add it idk
yes it form loads
but the combox has nothing
read that again
I didn't ask if the form loads. I asked if
Form1_Load
actually triggers.
If you have not wired up the event subscription for that method, it wont.um.. how can i tell if it triggers
im new ish sorry
or could i just copy my code into a second downloaded copy of the starter file and it would work?
You would use your debugger.
Set a breakpoint in visual studio
$debug
Tutorial: Debug C# code - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
ok so i believe that it is triggering
can you amke a screenshot of how the brakpoint was reached inside LoadGenres
because your last message doesnt sound really convincing
ok sure
also i just download the assignment starter again and copied everything and it still wont show the combobox list, so its the code i think but idk lol
all was the same but that
loadgenres method
you are just showing your code.. i wanted you to show me that the breakpoint in the right spot is getting reached.. for that you have to start your app
the red dot should go into loadgenre
thought you meant breakpoint in the code, what do you mean
ok
now that its in there start your app
nothing in the combobox still
i put the dot at line 83 at the loadgenres method
if you havent noticed any "weird" behavior i guess the method is never called
that means the form_load method is never excecuted
which means you have messed something up in the designer of the form
omg im dumb
i just double click form on the designer
so it would actually show up
could you phrase it so that people who arent sitting right next to you understand what you mean
LOL
one more thing in it that needs to be fixed: '
shows that it isnt valid no matter what
i see that genre is populated now... for that problem someone else can help you if you need more assistance
alright okok
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.