Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Fill combobox with objects (other than strings)

        public static void FillComboBoxWithOids(ComboBox comboBox)
        {
            comboBox.Items.Clear();

            List<string> oids = GetColumnValues(OidColumns.COL_OID);
            List<string> infos = GetColumnValues(OidColumns.COL_INFO);

            comboBox.Items.Add(new ComboBoxOidItem("", "-"));
            if ((oids != null) && (infos != null))
                for (int i = 0; i < oids.Count; i++)
                    comboBox.Items.Add(new ComboBoxOidItem(oids[i], infos[i]));

        }
        public class ComboBoxOidItem
        {
            public ComboBoxOidItem(string OID, string name)
            {
                _oid = OID;
                _name = name;
            }

            string _oid = null;
            string _name = null;

            public override string ToString()
            {
                return _name;
            }

            public string Name
            {
                get
                {
                    return _name;
                }
            }

            public string Oid
            {
                get
                {
                    return _oid;
                }
            }
        }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS