Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

Tab Control ComboBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Haumesser - 31 Aug 2004 19:41 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.