Hi,
Tell if I'm wrong but cmbDepartment is the combobox and you are adding items
to it.
What is the problem them?
Combobox accept any object, this mean there is no Tag property as is the
case with a ListViewItem.
Of course this is simple to add:
class ComboBoxItem{
string tag;
public string Tag { get {return tag;}}
object obj;
public object Value { get{return obj;}}
public override ToString() { return obj.ToString(); }
public ComboBoxItem( object o, string s) { obj = o; tag = s;}
}
then you do this:
foreach (DataRow drDepartment in objScanning.m_dsDepartments.Tables[0].Rows)
{
cmbDepartment.Items.Add( new ComboBoxItem( drDepartment["DepartmentName"] ,
drDepartment["DepartmentID"].ToString() );
You could do the Tag an object instance or if in 2.0 a template.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Jon Vaughan" <jo**********@hotmail.comwrote in message
news:Uu*********************@fe07.news.easynews.co m...
I'm changing my coding from VB.net to C#. When adding a local datatable
into a ComboBox, I would use soem code such as :
cmbDepartment.Items.Clear();
ArrayList arrTag;
foreach (DataRow drDepartment in
objScanning.m_dsDepartments.Tables[0].Rows)
{
cmbDepartment.Items.Add(drDepartment["DepartmentName"]);
arrTag.Add(drDepartment["DepartmentID"]);
}
After the loop I would attatch the Arraylist to my Combo box via the .tag,
but this isnt in C#. Whats the suggested method ?
Thanks