Here's one!
I have a Tab Control that consists of 4 Tab Pages. These pages will be
removed and added as needed as the user checks and unchecks certain
checkboxes.
On the Form_Load event, I am calling routines that populate the various
ComboBoxes List's that are contained by these Tab Pages. When these Combo
Boxes are populated, I initialize the text property with a 'String.Empty'.
At this point, the Tab Pages have not been added to the Tab Control.
Now, when the user adds a Tab Page to the Tab Control, such as :
tabStaff.TabPages.Add(tbSystemUser)
the text property is automatically being set the the first item in the list.
This is what I DON'T want to happen.
My Qutestions are: Why or How are these properties being set and How can I
prevent it?
Any ideas would be greatly appreciated,
Jeff
Mavisahdas - 01 Sep 2004 06:55 GMT
Hi jeff,
I hope ur problem is u have some Combo boxes in ur form and you are binding
it to some datacontrol say a dataset. And be default ur first item is set in
all the combo boxes... Is that what ur problem is ?
Ok now, let me answer ur questions one by one....
1. Why or How are these properties being set ?
When u bound ur combo box or if u have not set the item to be selected. then
by default ur first item will be selected.
2. How can i prevent it ?
a. If you they are data bound control. Add a empty row to the data table
which you are binding to the combo box like it.
dim ds as dataset = 'code to populate ur dataset
'now say for example u have 2 columns then do like this.
dim str(1) as string ' 1 represents no of columns that is you have to
declare a string array of length equaling ur no of columns.
str(0) = "--Select--" are what ever u want.to be display in the begining
str(1) = ""
ds.tables(0).rows.add (str)
'the bind this to the combo box... say combo1 is ur control name.
combo1.selectedIndex = combo1.items.count -1
thats it.
b. if your combo box is not a data bound control then by default assign some
item as the default one. Or add a empty item in the begining.
I hope this will help you.
Feel free to contact me any time... u can reach me at
sadhasivam1981@yahoo.com, sadhasivam1981@hotmail.com
With regards,
Sadha Sivam S,
Microsoft Community Star,
KMG Info Tech,
Bangalore, India.
Mobile : 9880397583