LeeHopkins
asked on
how to insert a value at index 0 of a combobox.
I have a query that I run to fill a combo box. it has a valuemember _recid and displaymember "text"
I want the first value to be valuemember =0 and displaymember to be "Please Select a Title"
How can i insert this new value at cboindex 0
I want the first value to be valuemember =0 and displaymember to be "Please Select a Title"
How can i insert this new value at cboindex 0
Dim magdt As DataTable = New DataTable
Dim strQuery As String
strQuery = "Select A_ID, A_Name from tbl_Art order by 2"
Dim myadapter As New SqlDataAdapter(strQuery, connstring)
myadapter.Fill(magdt)
Me.cboAName.DataSource = magdt
Me.cboAName.DisplayMember = "A_Name"
Me.cboAName.ValueMember = "A_ID"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Insert into dataset as
ds.Tables(0).Rows.InsertAt (ds.Tables (0).NewRow , 0)
ds.Tables(0).Rows(0)(Displ ayMember) = Display text
ds.Tables(0).Rows(0)(Value Member) = 0
ds.Tables(0).Rows.InsertAt
ds.Tables(0).Rows(0)(Displ
ds.Tables(0).Rows(0)(Value
magdt.Tables(0).Rows.Inser tAt(magdt. Tables(0). NewRow, 0)
magdt.Tables(0).Rows(0)(A_ Name) = "Please Select a Title"
magdt.Tables(0).Rows(0)(A_ ID) = 0
magdt.Tables(0).Rows(0)(A_
magdt.Tables(0).Rows(0)(A_
ASKER
i like this method it is very flexable on adding other items
Me.cboAName.Items.Insert(0