Results 1 to 5 of 5

Thread: Creating borders around (user)controls

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    4

    Creating borders around (user)controls

    Hi

    I have made a usercontrol that has a border around it. I've done this by creating a rect. shape inside the control that always maintains its width and height to be 1px less than the control width/height. This is so that when the control is resized in the main form, the border remains.

    The problem is that at certain measurements the shape does not conform to exactly ctlWidthorHeight - 1px. Instead, it overflows and partly becomes invisible.

    I'm looking for a better way to make a constant border around my usercontrol. How can I do this?
    Abhishek

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Set the BorderStyle to Fixed Single.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    You can set it in the designer for the UserControl. Then, if you want to be able to change it, you'll have to make a property that changes the borderstyle.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Usercontrol.Borderstyle=1

    0 for flat
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Originally posted by crptcblade
    You can set it in the designer for the UserControl. Then, if you want to be able to change it, you'll have to make a property that changes the borderstyle.

    Here is the code
    VB Code:
    1. Option Explicit
    2.  
    3. Enum Borders
    4.     None = 0
    5.     Fixed = 1
    6. End Enum
    7.    
    8. Public Property Get BorderStyle() As Borders
    9.     BorderStyle = UserControl.BorderStyle
    10. End Property
    11.  
    12. Public Property Let BorderStyle(New_BorderStyle As Borders)
    13.     UserControl.BorderStyle = New_BorderStyle
    14.     PropertyChanged "BorderStyle"
    15. End Property
    16.  
    17. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    18.     BorderStyle = PropBag.ReadProperty("BorderStyle", 0)
    19. End Sub
    20.  
    21. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    22.     PropBag.WriteProperty "Borderstyle", UserControl.BorderStyle, 0
    23. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width