❔ newbie here. how to make combobox display values from 2d array 2nd column, and do nothing if null?
this is visual studio windows form app combobox
so i have a combobox called category. if i click the dropdown i want it to do nothing / display nothing if array is null. and if 2D array record has value, i want it it to display the 2nd column (category).
i havent really put any values until i click the Add button
my 2d array looks like this
static int max = 12; //max number of records
static int attributes = 4; //name, category, structure, definition fields
string?[,] arrayRecord = new string[max, attributes];
i tried this but doesnt work, how to fix this?
if (arrayRecord.Length == 0)
{
// does nothing
} else
{
comboBoxCategory.Items.Clear(); //Clear items
for (var i = 0; i < arrayRecord.Length; i++)
{
comboBoxCategory.Items.Add(arrayRecord[i, 1]);
}
}
ty..
6 Replies
is there a reason you dont use a list?
the teacher restrict us to use class structure or any collections like List 😦, auto fail if so
I think we still can use a list for temporary list, in a function for example, but the data itself must be stored in 2D array, so im scratching my head how to display the data from 2D array to a list
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.not resolved..
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.