|
-
Nov 25th, 2009, 01:05 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Combobox default item
How can I make a comboxbox list the first item in the collaction by default
in other words i have a collection list
1
2
3
4
5
When program loads I want combobox to load 1
Thanks
-
Nov 25th, 2009, 01:11 AM
#2
Re: Combobox default item
did you tried:
Code:
ComboBox1.SelectedIndex = 0
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Nov 25th, 2009, 01:14 AM
#3
Re: Combobox default item
Tip: you can set the combobox DropDownStyle property to DropDownList
this will remove the empty value from your combobox.
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Nov 25th, 2009, 01:17 AM
#4
Hyperactive Member
Re: Combobox default item
use following code
Code:
Combobox.selectedIndex = 1
basically, Combobox.selectedIndex will accept/returns an integer value of item in List
MCP, MCTS, Microsoft MVP [Asp.Net/IIS]
For more .NET development tips visit .NET Tips
If the post is useful then please  Rate it
-
Nov 25th, 2009, 01:19 AM
#5
Thread Starter
Frenzied Member
Re: Combobox default item
 Originally Posted by motil
Tip: you can set the combobox DropDownStyle property to DropDownList
this will remove the empty value from your combobox.
Thats what I thought but it doesnt work??
-
Nov 25th, 2009, 01:21 AM
#6
Re: Combobox default item
do you set the selectedindex to 0 after you populating the cb?
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Nov 25th, 2009, 01:32 AM
#7
Hyperactive Member
Re: Combobox default item
hey billboy,
u have 5 items in your cmbbox, isn't it ???
so u have bydefault 1 as selected always..right ???
if u want the same then just fill the list and then after populating it...set selectedIndex = 1
MCP, MCTS, Microsoft MVP [Asp.Net/IIS]
For more .NET development tips visit .NET Tips
If the post is useful then please  Rate it
-
Nov 25th, 2009, 01:36 AM
#8
Thread Starter
Frenzied Member
Re: Combobox default item
I must be blind i dont see a property setting for selected index, do I have to code it ??
-
Nov 25th, 2009, 01:40 AM
#9
Re: Combobox default item
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("1")
ComboBox1.Items.Add("2")
ComboBox1.Items.Add("3")
ComboBox1.Items.Add("4")
ComboBox1.SelectedIndex = 0
End Sub
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Nov 25th, 2009, 01:40 AM
#10
Hyperactive Member
Re: Combobox default item
you have to do code for it like this...
just do the code on your form load event
Code:
//fill combo box code here
Combobox1.selectedIndex = 1
MCP, MCTS, Microsoft MVP [Asp.Net/IIS]
For more .NET development tips visit .NET Tips
If the post is useful then please  Rate it
-
Nov 25th, 2009, 01:43 AM
#11
Thread Starter
Frenzied Member
Re: Combobox default item
 Originally Posted by motil
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("1")
ComboBox1.Items.Add("2")
ComboBox1.Items.Add("3")
ComboBox1.Items.Add("4")
ComboBox1.SelectedIndex = 0
End Sub
ok thanks
I thought there was aproperty setting in the propertys window i was missing
LOL
Thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|