Richtextbox border

MagnusVS

Member
Joined
Jun 29, 2006
Messages
10
Programming Experience
1-3
Hi!

I'm trying to make a richtextbox in visual studio 2005, but the border is 3d even though I'm trying to make it standard. Does anybody know how to fix this or is it a bug?
 
What do you mean the border is still 3d? In 2003 you have border style property i assume in 2005 it is the same. When you say you are trying to make a richtextbox i assume you mean that you want to create a control that inherits from richtextbox and then customize the border? Am i right? if so then it is widely known as an all or nothing process.. meaning that you would have to override many of the methods and also do some fancy stuff with the wndproc sub because textbox and rixhtextbox are not .net native written controls, they are infact just wrappers around the old win32 textbox which makes them very hard to customize. However a while ago i came up with a much easier way to do this. If i am right in what i am saying then i could post back with a few hints on how i accomplished it.
 
rtb.JPG

I'm trying to make the richtextbox to get a 2d border like the textbox on this image, but I don't know how to do it. You don't have to bother if it's alot of work to explain it to me:)
 
As i said the textbox should have a borderstyle property, have a look in the properties window. In the drop down list there wil be a number of options, one of them should give you the effect you need.
 
Just a snippet from the docs: "The derived class, RichTextBox, does not support the BorderStyle.FixedSingle style. This style will cause the BorderStyle to use the BorderStyle.Fixed3D style instead."

Other option is BorderStyle.None. You will get the look you want if you place the RichTextBox inside a Panel that support BorderStyle.FixedSingle and set RTB.Dock=Fill + RTB.BorderStyle.None.
 
Thanks alot:) That works! Do you know why the border turns black instead of blue when it's changed to FixedSingle by the way? Is it possible to change the colour?
 
re:Bordercolor, not that I can find.
 
magnusVS, Later on i'll post how to draw a custom textbox border, i havent got the code with me at the moment. you can make it have round corners, dotted or dashed border, and any color that you want. Suffice to say though, if you'd like to try it yourself, you need to have the borderstyle set to fixed3d then the principle involves drawing over the top of the 3d border with the same color as the parents background. Once you've done that you can draw the border again however you like.
 
Back
Top