|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ListBox ControlmyDataTable = myDataSet.Tables(1) lbRole.Items.Clear() Dim dataRow_t As DataRow For Each dataRow_t In myDataTable.Rows lbRole.Items.Add(dataRow_t("Role_Desc")) Next dataRow_t lbRole.SelectedIndex = -1 Thought I would try using binding lbRole.Items.Clear() lbRole.DisplayMember = "role_desc" lbRole.ValueMember = "role_id" lbRole.DataSource = myDataSet.Tables(1) lbRole.SelectedIndex = -1 When I use looping method, I am able to set lbRole.SelectedIndex = -1 so no value is selected for the listbox. When I try the same method for the binding, I still get a value selected. I would like to bind, but need to be able allow input with no role selected. Thanks in advance... Dawg,
Does setting it twice have the desired effect? For example: lbRole.SelectedIndex = -1 lbRole.SelectedIndex = -1 Kerry Moorman Show quoteHide quote "strayd***@hotmail.com" wrote: > Creating listbox for Role and initially populating with loop > > myDataTable = myDataSet.Tables(1) > lbRole.Items.Clear() > Dim dataRow_t As DataRow > For Each dataRow_t In myDataTable.Rows > lbRole.Items.Add(dataRow_t("Role_Desc")) > Next dataRow_t > lbRole.SelectedIndex = -1 > > Thought I would try using binding > > lbRole.Items.Clear() > lbRole.DisplayMember = "role_desc" > lbRole.ValueMember = "role_id" > lbRole.DataSource = myDataSet.Tables(1) > lbRole.SelectedIndex = -1 > > When I use looping method, I am able to set lbRole.SelectedIndex = -1 > so no value is selected for the listbox. When I try the same method for > the binding, I still get a value selected. > > I would like to bind, but need to be able allow input with no role > selected. > > Thanks in advance... > > Thanks Kerry...
Not really. I see the the value for the lbRole.SelectedIndex is -1, but when looking at the listbox on the form, there still is a value selected. ?? D <strayd***@hotmail.com> wrote in message
Show quoteHide quote news:1145996259.082338.88460@i40g2000cwc.googlegroups.com... In ASP.Net, we would, after the data bind, add a new item to the list (empty > Creating listbox for Role and initially populating with loop > > myDataTable = myDataSet.Tables(1) > lbRole.Items.Clear() > Dim dataRow_t As DataRow > For Each dataRow_t In myDataTable.Rows > lbRole.Items.Add(dataRow_t("Role_Desc")) > Next dataRow_t > lbRole.SelectedIndex = -1 > > Thought I would try using binding > > lbRole.Items.Clear() > lbRole.DisplayMember = "role_desc" > lbRole.ValueMember = "role_id" > lbRole.DataSource = myDataSet.Tables(1) > lbRole.SelectedIndex = -1 > > When I use looping method, I am able to set lbRole.SelectedIndex = -1 > so no value is selected for the listbox. When I try the same method for > the binding, I still get a value selected. > > I would like to bind, but need to be able allow input with no role > selected. > > Thanks in advance... > item). Then you can set the SelectedValue/SelectedItem. HTH, Mythran Sraydaw,
Is it not a little bit strange that when you bind a box in the listbox. You want to bind one box to nothing, you can add an empty row in your datatable, but that gives your mostly more problems than results. Cor <strayd***@hotmail.com> schreef in bericht Show quoteHide quote news:1145996259.082338.88460@i40g2000cwc.googlegroups.com... > Creating listbox for Role and initially populating with loop > > myDataTable = myDataSet.Tables(1) > lbRole.Items.Clear() > Dim dataRow_t As DataRow > For Each dataRow_t In myDataTable.Rows > lbRole.Items.Add(dataRow_t("Role_Desc")) > Next dataRow_t > lbRole.SelectedIndex = -1 > > Thought I would try using binding > > lbRole.Items.Clear() > lbRole.DisplayMember = "role_desc" > lbRole.ValueMember = "role_id" > lbRole.DataSource = myDataSet.Tables(1) > lbRole.SelectedIndex = -1 > > When I use looping method, I am able to set lbRole.SelectedIndex = -1 > so no value is selected for the listbox. When I try the same method for > the binding, I still get a value selected. > > I would like to bind, but need to be able allow input with no role > selected. > > Thanks in advance... >
"Send To Mail Recipient"
Saving outlook email attachment? position in array using a string Recursion with a Tree View and checkboxes Missing DataGrid GetType question OnPaint vs. using a cached background image Click-Once Deployment of DLLs Automatically interacting with a search engine... RTF and word tables |
|||||||||||||||||||||||