|
-
Jul 25th, 2004, 08:17 PM
#1
Thread Starter
Junior Member
overriding datasource
basically I have a custom combobox i made, bound to a database for its source, and I need the initial value to be set to a blank line, but there seems no way to do it.
heres the code that should work:
Code:
'Add a blank row.
Dim DR = dsNormal.Tables(0).NewRow
DR(1) = ""
dsNormal.Tables(0).Rows.Add(DR)
With item01
.DataSource = dtNormal
.DisplayMember = dtNormal.Columns("name").ToString
.ValueMember = dtNormal.Columns("name").ToString
.SelectedIndex = item01.FindStringExact("")
'.SelectedValue = item01.FindStringExact(Nothing)
End With
item01.SelectedValue = item01.FindStringExact("")
item01.Text = ""
System.Console.WriteLine("it is: '" & item01.Text & "'")
"dtNormal" is the dataTable with the source. what happens with this code, I add a blank row to the dataset (datatable) then try to select it with item01.selectedIndex. It works, in the sense that the combobox is blank when I start the program. but other control's values in the form depend on the value of this one, and I need the .Text of this to be blank too, but that last System.Console.WriteLine() writes a non-blank item to output... even if right before that i do: item01.Text = Nothing.
any ideas on how to force a value in a comboBox that is bound to a datasource?
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
|