checkedlistbox

How come checkedlistbox does not have datasource ? how to bind to a list of values?

拟墨画扇 提交于 2019-12-04 23:25:30
I am developing a Winform and I need a checkedlistbox. I have the values stored in an object which has a List property: public static class Fields { public static IList<string> FieldList { get; set; } static Fields() { ...//populate FieldList } } Now I would like my CheckedListBox to use Fields.FieldList as datasource. After searching online I found I needed to set //in myForm_Load mycheckedListBox.DataSource = Fields.FieldList; But myCheckedListBox does not have a DataSource property. Am I missing something here? Per the documentation, it should have this property... http://msdn.microsoft.com

CheckedListBox - Search for an item by text

僤鯓⒐⒋嵵緔 提交于 2019-12-04 02:54:32
I have a CheckedListBox bound to a DataTable . Now I need to check some items programmatically, but I find that the SetItemChecked(...) method only accepts the item index. Is there a practical way to get an item by text/label, without knowing the item index? (NOTE: I've got limited experience with WinForms...) You can implement your own SetItemChecked(string item); private void SetItemChecked(string item) { int index = GetItemIndex(item); if (index < 0) return; myCheckedListBox.SetItemChecked(index, true); } private int GetItemIndex(string item) { int index = 0; foreach (object o in

How to add a margin to a CheckedListBox in .NET?

99封情书 提交于 2019-12-02 18:04:35
问题 I'm writing an windforms application using .NET (actually IronPython, but that's not relevant), and I have a CheckedListBox object in my GUI. It's working fine, it has about 20 items in a multicolumn layout. But I can't figure out how to give the thing a nice internal margin--I want to insert around 20 or 30 pixels of whitespace around the top, bottom, left, and right edges of the checkboxes. To be clear, I want the whitespace to appear between the border of the CheckedListBox and the

Programmatically Checking DataBound CheckListBox

孤街浪徒 提交于 2019-12-02 13:28:25
问题 I have a DataBound "CheckedListBox", I need to check some items on it. I tried with following code... if (!string.IsNullOrEmpty(search.Languages)) { string[] langs = search.Languages.Split(','); for (int i = 0; i < (langs.Length - 1); i++) { for (int j = 0; j < clbLang.Items.Count; j++) { string lng = clbLang.Items[j] as string; if (lng.Trim() == langs[i]) { clbLang.SetItemChecked(j, true); break; } } } } No errors, debuged execution is going through " checking " process, but finally I cannot

CheckedListBox data binding to checked state of Items

亡梦爱人 提交于 2019-12-02 08:08:57
问题 I tried to set DataSource of CheckedListBox like this: private void Form1_Load(object sender, EventArgs e) { checkedListBox1.DisplayMember = "Name"; checkedListBox1.ValueMember = "Checked"; _bindingList = new BindingList<CustomBindingClass>( new List<CustomBindingClass> { new CustomBindingClass {Checked = CheckState.Checked, Name = "Item1"}, new CustomBindingClass {Checked = CheckState.Checked, Name = "Item2"}, new CustomBindingClass {Checked = CheckState.Unchecked, Name = "Item3"}, });

Save CheckedListBox Items to Settings

爷,独闯天下 提交于 2019-12-02 07:40:26
问题 I am trying to maintain a list of checked items in a CheckedListBox in User Settings and then reload them upon Application load. In my Settings.settings file, I added the following: <Setting Name="obj" Type="System.Windows.Forms.CheckedListBox.ObjectCollection" Scope="User"> <Value Profile="(Default)" /> </Setting> And, on chkList_ItemCheck , I am doing the following: Properties.Settings.Default.obj = chkList.Items; Properties.Settings.Default.Save() But for some reason, when I exit the app,

Save CheckedListBox Items to Settings

限于喜欢 提交于 2019-12-02 05:44:32
I am trying to maintain a list of checked items in a CheckedListBox in User Settings and then reload them upon Application load. In my Settings.settings file, I added the following: <Setting Name="obj" Type="System.Windows.Forms.CheckedListBox.ObjectCollection" Scope="User"> <Value Profile="(Default)" /> </Setting> And, on chkList_ItemCheck , I am doing the following: Properties.Settings.Default.obj = chkList.Items; Properties.Settings.Default.Save() But for some reason, when I exit the app, re-open, and check the value of Properties.Settings.Default.obj , it is null . What am I doing wrong

CheckedListBox data binding to checked state of Items

纵饮孤独 提交于 2019-12-02 05:30:31
I tried to set DataSource of CheckedListBox like this: private void Form1_Load(object sender, EventArgs e) { checkedListBox1.DisplayMember = "Name"; checkedListBox1.ValueMember = "Checked"; _bindingList = new BindingList<CustomBindingClass>( new List<CustomBindingClass> { new CustomBindingClass {Checked = CheckState.Checked, Name = "Item1"}, new CustomBindingClass {Checked = CheckState.Checked, Name = "Item2"}, new CustomBindingClass {Checked = CheckState.Unchecked, Name = "Item3"}, }); checkedListBox1.DataSource = _bindingList; } And It's working but partially. I'm able to do the fallowing

Get item index from databound DevExpress CheckedListBoxControl

可紊 提交于 2019-12-02 00:09:22
问题 I am trying to find the index of a particular value from the CheckedListBoxControl. The CheckedListBoxControl has a DataSource, DisplayMember, ValueMember set to a DataTable and two columns receptively. Now I have to set the CheckedState Property to true by finding its index from CheckedListBoxControl by using some value from the ValueMember and then calling the SetItemChecked() method with that index. I'm not able to find any property or method which returns the index. Please help. 回答1: If a

Get item index from databound DevExpress CheckedListBoxControl

旧巷老猫 提交于 2019-12-01 21:33:41
I am trying to find the index of a particular value from the CheckedListBoxControl . The CheckedListBoxControl has a DataSource, DisplayMember, ValueMember set to a DataTable and two columns receptively. Now I have to set the CheckedState Property to true by finding its index from CheckedListBoxControl by using some value from the ValueMember and then calling the SetItemChecked() method with that index. I'm not able to find any property or method which returns the index. Please help. If a list box control is bound to a data source, you can iterate throught all listbox items using the the