checkedlistbox

Winforms - Adjust width of vertical scrollbar on CheckedListBox

此生再无相见时 提交于 2019-11-29 11:52:36
I have a CheckListBox on my form but I want to make the scrollbar wider as users are using touch screens not a mouse. How can I change the scroll bar width? EDIT: I am talking about the width of the vertical scrollbar To change the physical size of the scrollbar, see this . This came from the following page: Horizontal Scrollbar in ListBox . I modified it for Winforms and it worked for me: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices;

Is there “DisplayMember” and “ValueMember” like Properties for CheckedListBox control? C# winforms

一世执手 提交于 2019-11-29 09:35:16
I have this DataTable with the following structure: ID | VALUE ---------------- 1 | Item 1 2 | Item 2 3 | Item 3 And I display the values from the DataTable into a CheckedListBox control by adding each row as an item. But how can I include the ID? Is there "DisplayMember" and "ValueMember" like Properties for CheckedListBox control? Well yes, there are DisplayMember and ValueMember properties on CheckedListBox , although the docs for ValueMember claim it's "not relevant to this class". Here's a quick example showing DisplayMember working: using System; using System.Drawing; using System

CheckedListBox allowing only one item to be checked

青春壹個敷衍的年華 提交于 2019-11-28 23:35:15
In my CheckedListBox app I want to allow only a single item to be checked. I have these properties already set checkOnClick = true; SelectionMode = One; Any advise will be appreciated uncheck all other items in ItemCheck event as below : private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) { for (int ix = 0; ix < checkedListBox1.Items.Count; ++ix) if (ix != e.Index) checkedListBox1.SetItemChecked(ix, false); } the best way to do this is like this: private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) { if (e.NewValue == CheckState.Checked &&

How to change CheckedListBox item vertical space

a 夏天 提交于 2019-11-28 13:42:01
I need to change the vertical space for CheckedListBox items so they fit with the text boxes on the other side: How to do this ? After doing some research I found out that CheckedListBox inherits ListBox , so it must have its public property ItemHeight , but for some reason it doesn't I tried this : ListBox l = CheckedList as ListBox; l.ItemHeight = 30; but it didn't work The default implementation of ItemHeight property of CheckedListBox is, public override int ItemHeight { get { // this should take FontHeight + buffer into Consideration. return Font.Height + 2; } set { } } you can cleanly

Can I use a DrawItem event handler with a CheckedListBox?

允我心安 提交于 2019-11-28 11:33:06
问题 I would like to override the text displayed when an item is added to a checked list box. Right now it is using obj.ToString(), but I want to append some text, without changing the objects ToString method. I have seen examples of handling the DrawItem event for ListBoxs, but when I try to implement them, my event handler is not called. I have noted that the Winforms designer does not seem to allow me to assign a handler for the DrawItem event. Being stubborn, I just added the code myself

How to detect if items are added to a ListBox (or CheckedListBox) control

百般思念 提交于 2019-11-28 09:01:32
This seems like a fundamentally simple question. I have a WinForms dialog box with a listbox. This control is not populated via data-binding but is filled with calls to listBox.Items.Add (obj); It is possible that this call can be made asynchronously from various places and I would like to hook the listbox and watch for changes in its data members so that I can perform other UI changes (such as enable or disable controls which interact with the listbox based on the number of items in the list). Unfortunately, unless I'm being completely clueless, there does not seem to be an event or virtual

How to get value of checked item from CheckedListBox?

久未见 提交于 2019-11-27 22:43:51
I have used a CheckedListBox over my WinForm in C#. I have bounded this control as shown below - chlCompanies.DataSource = dsCompanies.Tables[0]; chlCompanies.DisplayMember = "CompanyName"; chlCompanies.ValueMember = "ID"; I can get the indices of checked items, but how can i get checked item text and value. Rather how can i enumerate through CheckedItems accessing Text and Value? Thanks for sharing your time. Cast it back to its original type, which will be a DataRowView if you're binding a table, and you can then get the Id and Text from the appropriate columns: foreach(object itemChecked in

CheckedListBox allowing only one item to be checked

点点圈 提交于 2019-11-27 15:04:17
问题 In my CheckedListBox app I want to allow only a single item to be checked. I have these properties already set checkOnClick = true; SelectionMode = One; Any advise will be appreciated 回答1: uncheck all other items in ItemCheck event as below : private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e) { for (int ix = 0; ix < checkedListBox1.Items.Count; ++ix) if (ix != e.Index) checkedListBox1.SetItemChecked(ix, false); } 回答2: the best way to do this is like this: private void

How to change CheckedListBox item vertical space

久未见 提交于 2019-11-27 07:48:54
问题 I need to change the vertical space for CheckedListBox items so they fit with the text boxes on the other side: How to do this ? After doing some research I found out that CheckedListBox inherits ListBox , so it must have its public property ItemHeight , but for some reason it doesn't I tried this : ListBox l = CheckedList as ListBox; l.ItemHeight = 30; but it didn't work 回答1: The default implementation of ItemHeight property of CheckedListBox is, public override int ItemHeight { get { //

How to detect if items are added to a ListBox (or CheckedListBox) control

不羁岁月 提交于 2019-11-27 02:40:26
问题 This seems like a fundamentally simple question. I have a WinForms dialog box with a listbox. This control is not populated via data-binding but is filled with calls to listBox.Items.Add (obj); It is possible that this call can be made asynchronously from various places and I would like to hook the listbox and watch for changes in its data members so that I can perform other UI changes (such as enable or disable controls which interact with the listbox based on the number of items in the list