collectionControl

quwiltw

Well-known member
Joined
Sep 18, 2001
Messages
486
Location
Washington, D.C.
I just read divils tutorial on CollectionControl, its great. I do have a question, if the controls are inherited from built-in controls, in my case an inherited RadioButton (inherited to add a RadioValue property), how do I get it to draw itself in the designer? and at runtime?
 
Im getting there... Calling InvokePaint on each of the contained controls seems to work for one, but now it makes me realize that either only one is being added or its dropping them on top of each other. Still searching...
 
What behaviour do you want the radio buttons to have? You should be able to host them on the design surface if youve created them with a call to CreateComponent on IDesignerHost. You can add them to your control with Controls.Add.
 
I want the radio buttons to have a Value attribute that can be set at design time. Then I can take the RadioCollectionControl and bind to it and have its Value make the correct selection on the contained radio buttons. It relates to the question I asked the other day
http://www.computerhelp.forum/showthread.php?s=&threadid=70264
... then I saw your article and figured this would be a good generic way to solve the problem instead of having to create individual UserControls for each situation.

For now, it paints the first one fine but I think its setting every one after that on top of the first. Im trying to better understand the CalculateLayout cause I suspect its somewhere in there. Any ideas, let me know.
 
Since these are real controls you are hosting, a great deal of my article doesnt apply. All the CalculateLayout function need do in your case is to set the position of the radiobutton controls once youve added them with Controls.Add.

By default, the radiobuttons will have a ControlDesigner associated with them, so they will be selectable and youll be able to edit their properties in the propertygrid. However you probably wont see the selection rectangle because your parent control designer wont inherit from ParentControlDesigner.
 
Thanks, finally got it, now Im trying to find a place to force the main control to repaint itself. I tried putting it after the commit in OnAddButton() but that doesnt work, Ill keep trying. Im getting close though. Right now I have to resize the control in the designer to get all the radiobuttons to show.

btw. my problem was that i was still going at your Buttons property instead of directly adding to the Controls property.
 
Beautiful!!! asking it to repaint itself wasnt enough, since Im no longer going through Buttons.Add(), I had to make a call to CalculateLayout() to both reposition and repaint. Now I need to figure out a way to get the selection border back.
 
When you originally posted this thread I had a quick go at doing what youre doing, and to get the selection border I had to do the following:

- Listen for the SelectionChanged event from ISelectionService (youre probably already doing so)
- Force any radiobutton that should (or shouldnt anymore) have a selection rectangle to repaint itself
- In your RadioButton designer, override OnPaintAdornments. Then use ControlPaint.DrawSelectionFrame to draw the selection frame on top of the controls normal graphics.
 
Back
Top