Designer problem

Engine252

Regular
Joined
Jan 8, 2003
Messages
99
I want to create a control that has a panel in it (like the tabpage control)
or in some cases a wizardpage where the page itself isn't selectable, but the internal panel is. When you select the page or the control in designer you can see the internal panel selected (locked) well i want to do the same
my guesse is i got to do something with a parentcontroldesigner but i can't seem to select the internal panel.

please look at the image i added in the attachment to see what i mean
 

Attachments

There are a couple of designer functions that can do that. I would suggest checking out
this site . He has quite a bit of good information on his site regarding custom control design. I believe he's also a Moderator here on this site.

If I'm not mistaken, Overriding SelectionRules in your control designer is one way. I believe your can also use the PaintAdornments method. I think there is also a function in ControlPaint that handles what you're looing for.
 
i am aware of divil his site and his articles and no there's is nothing in his samples / tutorials that do sutch a thing.

the problem is that in disigner i can't seem the set the inner panel as the selected component
 
Engine252 said:
i am aware of divil his site and his articles and no there's is nothing in his samples / tutorials that do sutch a thing.

the problem is that in disigner i can't seem the set the inner panel as the selected component

In the parent container form you should use the ISelectionService to make the change (which is in the example Tim provides on his site). You just need to download the example, which has C# and VB.NET examples

Code:
<Designer(GetType(MyControlDesigner))> _
Public Class YourParentControl
   Inherits System.Windows.Forms.UserControl

   +[Windows Generated Code]

   Friend Sub OnSelectionChanged()
      Dim s as ISelectionService = DirectCast(GetService(GetType(ISelectionService)), ISelectionService)
     Dim ct as TheControlYouWantToSelect
     Dim ctr as Control

     For each ctr in YourControlCollection
        If TypeOf ctr is TheControlYouWantToSelect Then
            ct = DirectCast(ctr, TheControlYouWantToSelect)
            If s.PrimarySelection = ct Then
               'Draw your graphics or call your drawing sub
            End If
        End If
     Next
   End Sub

   Protected Overrides OnMouseDown(ByVal e as MouseEventArgs)
     MyBase.OnMouseDown(e)
     Dim s as ISelectionService
     Dim aList as ArrayList
     Dim rect as Rectangle
     Dim ct as TheControlYouWantToSelect
     Dim ctr as Control

     For each Control in YourControlCollection
         If TypeOf ctr is TheControlYouWantToSelect
           ct = DirectCast(ctr, TheControlYouWantToSelect)
           rect = ct.Bounds
           If(rect.Contains(e.x, e.y)) Then
               s = DirectCast(GetService(GetType(ISelectionService)), ISelectionService)
               aList = new ArrayList()
               aList.Add(ct)
               s.SetSelectedComponents(aList)
               Exit For
           End If
        Next
End Sub
End Class
Public Class MyControlDesigner
   Inherits ControlDesigner

   Private MyControl as YourParentControl
   Public Overrides Sub Initialize(ByVal component as IComponent)
       MyBase.Initialize(component)
       MyControl = DirectCast(component, YourParentControl)

       Dim s as ISelectionService = DirectCast(GetService(GetType(ISelectionService)), ISelectionService)
       Dim c as IComponentChangeService = DirectCast(GetService(GetType(IComponentChangeService)), IComponentChangeService)

      AddHandler s.SelectionChanged, Addressof OnSelectionChanged
      AddHandler c.OnComponentRemoving, Addressof OnComponentRemoving
  End Sub

  Private Sub OnSelectionChanged(ByVal sender as Object, ByVal e as EventArgs)

    MyControl.OnSelectionChanged()
  End Sub

  'the rest of the designer code
End Class
 
no that didn't do the trick see i have a control (parent) in this parentControl
there is a panel hosted now if the designer of this control you can just see 1 control the parent and i would like the user to be able to add controls in this internal panel in order to do this i have to make it visible or select it wenever the parent control is selected well this is wath's not working i can see the designer flickering but it won't select the inner panel.
 
Back
Top