开发者

checked list box Data Source Does

I have bounded a CheckedListBox To a DataSource Which has been declared in class scope , but when I update DataSource in some method , CheckedListBox does not change , but when i r开发者_StackOverflow社区ecall following codes again it changes:

private void UpdateDataSource(string textToSearch )
{

    dsContacts = dbSms.fillDataSet("Select * From Contacts Where ContactName Like'%" + textToSearch + "%'", "Contacts");

    chListBox.DataSource = dsContacts.Tables["Contacts"];
    chListBox.DisplayMember = "ContactName";
    chListBox.ValueMember = "ContactNumber";

}


It's the DataSource setter that's triggering the update. When you set it to a new value it will refresh the check list box.


use refresh method.

private void UpdateDataSource(string textToSearch )
{

    dsContacts = dbSms.fillDataSet("Select * From Contacts Where ContactName Like'%" + textToSearch + "%'", "Contacts");

    chListBox.DataSource = dsContacts.Tables["Contacts"];
    chListBox.DisplayMember = "ContactName";
    chListBox.ValueMember = "ContactNumber";
    chListBox.Refresh();

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜