We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Sample of dropdown Checked ListBox in grid

Hi, I am using Databound grid. Do you have a sample with a dropdown checked listbox sample for this? thanks, - Reddy

6 Replies

AD Administrator Syncfusion Team June 3, 2004 03:02 PM UTC

We ship a sample in the 2.0 code base,\Grid\Samples\In Depth\DropDownFormAndUserControlSample that shows how to put a control in a dropdown form or in a dropdown user control (either model or modelless). And the example control we use is a CheckedListBox. I think the code should work OK in (as long as you comment out any new properties being set in the designer code - you''ll see syntax error when you try to compile - if there are any). CS_7730.zip

AD Administrator Syncfusion Team June 9, 2004 08:06 PM UTC

Clay, I am using the DropDownUserControl technique. Is there any way to get the focus into the drop down user control''s checked listbox by default when the combobox is dropped down? I tried adding ddUser.Focus() at the end of DropDownContainerShowingDropDown() method, right after ddUser.Visible = true. It is not working. thanks, - Reddy

AD Administrator Syncfusion Team June 9, 2004 09:32 PM UTC

Even if you place a CheckedListBox directly on a Form, it takes two clicks to change a check. The first click highlights the item, and the second click checks/unchecks the item. If you want to select an item in the checkedlistbox when the user control gets focus, I think you will have to explicitly do it, and not just set the control focus. So, maybe make the checkedListBox1 public so you can access it out of the class, and then use code like: ddUser.Focus(); ddUser.checkedListBox1.SelectedIndex = 0; to select the first item.

AD Administrator Syncfusion Team June 10, 2004 01:28 PM UTC

For testing I added a textbox before the checked listbox and set proper tabstops. It is not getting focus either. When the ''CheckOnClick'' property of the checked listbox is true, it will automatically check when you click on a checkbox. It does not require two clicks. Since the checked listbox does not support multiple columns, I am using a databound grid and making it look like checked listbox. Setting the checkedlistbox.SelectedIndex = 0 does not work. I added Enter/Leave handlers and printed a debug statement. As soon as I click the drop down button in the main form, I am getting "DDUser got focus" and "DDUser lost focus" immediately. So, I think grid is requesting focus (may be to current cell ??) back after DropDownContainerShowingDropDown() is called. Any ideas... thanks, - Reddy

AD Administrator Syncfusion Team June 10, 2004 02:22 PM UTC

This seemed to work for me. Subscribe to the user control''s VisibleChanged event in the renderer''s constructor. Then in the handler, do a fake mouse click on the control in the user control you want to have focus.
//in renderer''s contructor
this.ddUser.VisibleChanged += new EventHandler(ddUser_VisibleChanged);

//the handler
private void ddUser_VisibleChanged(object sender, EventArgs e)
		Point p = new Point(2,2); //just some point in the checkedlistbox
		Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.ddUser.checkedListBox1, p);

AD Administrator Syncfusion Team June 10, 2004 03:30 PM UTC

Clay, You da man!!! As usual, it works like a charm. - Reddy

Live Chat Icon For mobile
Up arrow icon