public void TestStringCombobox()
        {
            TCmbVersatile cmb = new TCmbVersatile();

            cmb.SetDataSourceStringList("test1,test2,test3");
            Assert.AreEqual(3, cmb.Items.Count, "combobox should have 3 inital items");

            cmb.SetSelectedString("test2");
            Assert.AreEqual("test2", cmb.GetSelectedString(), "get the second string, normal");

            cmb.SetSelectedString("invalid");
            Assert.AreEqual("test2", cmb.GetSelectedString(), "get the second string, after invalid assignment");
            Assert.AreEqual(3, cmb.Items.Count, "keep the items even after invalid assignment");
        }
        public void TestDataViewCombobox()
        {
            TCmbVersatile cmb = new TCmbVersatile();

            DataTable t = new DataTable();

            t.Columns.Add("value", typeof(string));
            t.Columns.Add("display", typeof(string));

            DataRow r = t.NewRow();

            r[0] = "test1";
            r[1] = "Test 1";
            t.Rows.Add(r);

            r    = t.NewRow();
            r[0] = "test2";
            r[1] = "Test 2";
            t.Rows.Add(r);

            r    = t.NewRow();
            r[0] = "test3";
            r[1] = "Test 3";
            t.Rows.Add(r);

            cmb.DisplayMember = "display";
            cmb.ValueMember   = "value";
            cmb.DataSource    = t.DefaultView;
            cmb.EndUpdate();
            cmb.Invalidate();

            // need to add combobox to a form, otherwise the cmb.Items will be empty
            System.Windows.Forms.Form frm = new System.Windows.Forms.Form();
            frm.Controls.Add(cmb);
            frm.Show();

            Assert.AreEqual(3, ((DataView)cmb.DataSource).Count, "combobox should have 3 inital items in the data source");
            Assert.AreEqual(3, cmb.Items.Count, "combobox should have 3 inital items in the items list");

            cmb.SetSelectedString("test2");
            Assert.AreEqual("test2", cmb.GetSelectedString(), "get the second string, normal");

            cmb.SetSelectedString("invalid");
            Assert.AreEqual("test2", cmb.GetSelectedString(), "get the second string, after invalid assignment");
            Assert.AreEqual(3, cmb.Items.Count, "keep the items even after invalid assignment");
        }