本文介绍了如何在清单框内增加价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在combobox_SelectedIndexChanged事件中从数据库的清单框添加值.
为此,我使用了这些代码
Hi,
i am trying to add value in checklistbox from database on combobox_SelectedIndexChanged event.
for that i used these code
Dim a, b As Integer
Dim h As String
h = Convert.ToString(comboBox3.Text)
commObj = New OleDbCommand("SELECT Test FROM SubTest WHERE MainTest = '" & h & "' ", cnn)
myAdapter = New OleDbDataAdapter(commObj)
myAdapter.Fill(myDataSet1, "cDetails")
For Each ds As DataRow In myDataSet1.Tables("cDetails").Rows
CheckedListBox1.Items.Add(ds("SubTest").ToString())
Next
但是主要的问题是,当我在清单列表中的那个时间在清单框中得到输出时,我们得到了8个空白项目(空白),后来数据库选择的项目开始了
我的问题是为什么那里有这8个空间.
我正在尝试许多可能性,但无法获得解决方案:-(
尝试解决这些问题.
but main issue is that when i got output in checklistbox that time at list starting we get 8 blank item( blank space ) and later database selected item start
my question is why these 8 space are present there.
i am trying so many possibility but cant get solution :-(
try to help for these problem.
推荐答案
CheckedListBox1.DataValueField = "Test";
CheckedListBox1.DataTextField = "Test";
CheckedListBox1.DataSource = myDataSet1;
CheckedListBox1.DataBind();
不需要像任何将项目附加到复选框列表的循环
no need to do like any loop for attaching items to checkbox list
这篇关于如何在清单框内增加价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!