checklistbox

Set checked items in checkedlistbox from list or dataset

元气小坏坏 提交于 2019-12-10 15:14:55
问题 I have a CheckedListBox and I would like to check all the items that are in another List. This code does not work since the CheckedItems property is read-only and the types do not match, but it gives the best idea of what I want to do. checkedListBox1.DataSource = DataSetSelectAll().Tables[0]; checkedListBox1.ValueMember = "id_table"; checkedListBox1.DisplayMember = "name"; List<tableClass> list = MyCheckedList(); checkedListBox1.CheckedItems = list; I know this is wrong but do not know how

C# CheckBox List Selected Items.Text to Labels.Text

这一生的挚爱 提交于 2019-12-06 11:36:19
问题 I have a CheckBoxList and 5 labels. I would like the text value of these Labels to be set to the 5 selections made from the CheckBoxList after the user clicks on a button. How would I get this accomplished? Thanks in advance. 回答1: bind an event to a button, iterate trough the Items property of the CheckBoxList set the text value according to the selected property of the listitem like: protected void button_Click(object sender, EventArgs e) { foreach (ListItem item in theCheckBoxList.Items) {

C# CheckBox List Selected Items.Text to Labels.Text

女生的网名这么多〃 提交于 2019-12-04 17:24:04
I have a CheckBoxList and 5 labels. I would like the text value of these Labels to be set to the 5 selections made from the CheckBoxList after the user clicks on a button. How would I get this accomplished? Thanks in advance. bind an event to a button, iterate trough the Items property of the CheckBoxList set the text value according to the selected property of the listitem like: protected void button_Click(object sender, EventArgs e) { foreach (ListItem item in theCheckBoxList.Items) { item.Text = item.Selected ? "Checked" : "UnChecked"; } } to add a value you could do: foreach (ListItem item

Check all checkboxes in checkboxlist with one click using c#

*爱你&永不变心* 提交于 2019-12-02 23:54:27
I want to have a button that once clicked, it will select all checkboxes in my checklistbox. I've search the possible answers but I always see examples for asp.net and javascript. I am using Windows form in c#. Thank you for any response. for (int i = 0; i < checkedListBox1.Items.Count; i++) { checkedListBox1.SetItemChecked(i, true); } Call a method from code behind in C# and write this piece of code, then you could be able to check/uncheck them. This checks or uncheck all the check boxes present in the checkboxlist. Hope it might help. foreach (ListItem item in CheckBoxList.Items) { item

Limiting checked items of TCheckListBox on Delphi

依然范特西╮ 提交于 2019-12-02 01:14:39
问题 I want to limit a TCheckListBox. I desire only 2 items should be checked, and all unchecked items will be disabled and grayed. Since the checked / unchecked items are dynamic, i can not use a static itemIndex. Here is what i tried, but i got "Out of chip bounds" error. On click event of my CheckListBox ; var NumberOfCheckedItems, I: Integer; begin NumberOfCheckedItems := 0; for I := 0 to CkLst1.Count - 1 do begin if CkLst1.Checked[I] then NumberOfCheckedItems := NumberOfCheckedItems + 1; end;

Limiting checked items of TCheckListBox on Delphi

让人想犯罪 __ 提交于 2019-12-01 22:31:24
I want to limit a TCheckListBox. I desire only 2 items should be checked, and all unchecked items will be disabled and grayed. Since the checked / unchecked items are dynamic, i can not use a static itemIndex. Here is what i tried, but i got "Out of chip bounds" error. On click event of my CheckListBox ; var NumberOfCheckedItems, I: Integer; begin NumberOfCheckedItems := 0; for I := 0 to CkLst1.Count - 1 do begin if CkLst1.Checked[I] then NumberOfCheckedItems := NumberOfCheckedItems + 1; end; if NumberOfCheckedItems > 1 then begin CkLst1.Checked[I] := Enabled; CkLst1.Enabled := FALSE; CkLst1

Getting CheckBoxList Item values

不羁的心 提交于 2019-11-30 18:42:35
I have a CheckBoxList which I'm populating with data. When I attempt to retrieve the checked items from the list I can only grab the item ordinal, I cannot get the value. I've read that you can use Items[i].Value however when I try to do this I get an error stating that there is no extension method 'value'. Here's the code I'm using to try and grab the information (note the GetItemText(i) actually only gives me the item position, not the text for the item) private void btnGO_Click(object sender, EventArgs e) { for (int i = 0; i < chBoxListTables.Items.Count; i++) { if (chBoxListTables

Getting CheckBoxList Item values

时光总嘲笑我的痴心妄想 提交于 2019-11-30 03:19:12
问题 I have a CheckBoxList which I'm populating with data. When I attempt to retrieve the checked items from the list I can only grab the item ordinal, I cannot get the value. I've read that you can use Items[i].Value however when I try to do this I get an error stating that there is no extension method 'value'. Here's the code I'm using to try and grab the information (note the GetItemText(i) actually only gives me the item position, not the text for the item) private void btnGO_Click(object

Programmatically Check an Item in Checkboxlist where text is equal to what i want

北城余情 提交于 2019-11-27 05:45:16
问题 In C#, I am trying to Check an item in a CheckBoxList where the text equals what I require. I would modify the code to check items that exist in the database. If you would like an example, i need to select the checklistbox item that equals to abc 回答1: Assuming that the items in your CheckedListBox are strings: for (int i = 0; i < checkedListBox1.Items.Count; i++) { if ((string)checkedListBox1.Items[i] == value) { checkedListBox1.SetItemChecked(i, true); } } Or int index = checkedListBox1