combobox
Hi all,
I was wondering if it is at all possible to manually define index values to combo boxes as well as adding the display items. I've tried various ways but got kinda stuck. I have no trouble with the list items themselves, I just need a way to use a column from a table to use as the index so I can update the display of the datagrid according to whats selected from the list.
eg. I'm breaking down datagrid listings according to the category selected from the combobox list...
I'm using MySQL Connector/Net with Visual Studio 2005 so I have to do this manually, otherwise it would be a snap.
I'm pretty new to C# and the world of .NET so I appreciate any help anyone can offer.
AnttiPosted Dec 14, 2005, 1:28 AM
For DataRow usage, see following page in MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatarowclasstopic.asp
>>Is this a bug with .NET 2.0 perhaps?
Usually the bug is in our own code.
TerryPosted Dec 14, 2005, 12:04 AM
Thought I had better supply the code I'm having trouble with. Just spent the whole day on this searching around and it seems I'm doing it right.
As you can see I've tried creating a table myself and it still doesn't work. Is this a bug with .NET 2.0 perhaps?
DataTable dsTbl = new DataTable("Category");
dsTbl.Columns.Add("catid", typeof(int));
dsTbl.Columns.Add("name", typeof(string));
object[] row = new object[2];
row[0] = 28;
row[1] = "Stupid";
dsTbl.Rows.Add(row);
catCombo.DataSource = dsTbl;
catCombo.ValueMember = "catid";
catCombo.DisplayMember = "name";