Link to home
Start Free TrialLog in
Avatar of pointeman
pointemanFlag for United States of America

asked on

CheckedListbox Control Items Add?

I have a Win app using a custom user control which contains a CheckedListbox.

Q. How can I add items to the custom control like: checkedListbox.Items.Add(...)?
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you have the source code ... ?


 public void AddItemToListBox ( ListViewItem lvItem )
 {
    myCustomControl.GetListControl().Items.Add ( lvItem );
 }
 
 

Open in new window

Avatar of pointeman

ASKER

The first code you provided worked famously. What does your latest code do?
 public void AddItemToListBox ( ListViewItem lvItem )
{
    myCustomControl.GetListControl().Items.Add ( lvItem );
}
 
opps, spoke to soon. I thought it was part of the actual control, but I see it access the control for items...
The last code is not mine, it is williamcampbell's code. He assumes a different underlying control, but your control does not allow ListViewItems, not even ListItems. It only allows general objects (which could be ListViewItems, but I'm not sure that would work).

I'm not sure what you mean with your last statement. Do you mean it doesn't work for you anymore?
This code works well:
public CheckedListBox.ObjectCollection Items { get { return checkedListBox.Items; } }
I have a new problem: The user control makes some labels and textboxes disappear in VS designer. Also cannot place more than one custom user control on win form without making eithor or both disappear.
 
That's quite a different problem, I won't mind helping you there, but consider the one q. per thread principle from EE... The place where you should look is in the this.DesignMode (to distinguish design mode code to run mode code). Do you mean other controls that do not belong to this control? Sound like some repaint problem, or that the actual size of your user control (the canvas) is larger than it should be.