'---Select----' is first items in all combobox!

prosys

Member
Joined
Aug 7, 2008
Messages
13
Programming Experience
Beginner
i using VB.Net to developing my application.
in forms i have comobox, in combobox datas are filled by using datasource from process layer.

i want '--Select--' is first items in all combobox. but i tried my ways, i cann't bring it.

any solution, pl share with me.

thanks in advance.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
Since they're databound you cant simply do a ComboBox.Items.Insert(0, "--Select-") you'll have to modify the query to be a Union where the first Select statement is Select "--Select-" As FieldOne ....

That'll cause you to get "--Select-" as the first row in the dataset then the actual data following
 

MattP

Well-known member
Joined
Feb 29, 2008
Messages
1,206
Location
WY, USA
Programming Experience
5-10
Try adding the row to the DataTable then appending the data like this.

VB.NET:
Me.MyDataSet.MyDataTable.Clear()
Me.MyDataSet.MyDataTable.AddMyDataTableRow("--Select--")
Me.MyTableAdapter.ClearBeforeFill = False
Me.MyTableAdapter.Fill(Me.MyDataSet.MyDataTable)
Me.ComboBox1.SelectedIndex = 0
 
Top Bottom