473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Painting a textbox Border--the Answer

After spending a morning wading through all the the Wrong answers and
responses I have figured out how to change the border on a textbox.

Here is the code:

Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal
hwnd As Integer, ByVal hdc As Integer) As Integer
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Const WM_PAINTBKG As Integer = 15
If m.Msg = WM_PAINTBKG Then
Dim g As Graphics = Me.CreateGraphics
Dim mypen As Pen = New
Pen(System.Drawing.SystemColors.GrayText, 1)
Dim width As Integer = Bounds.Width - 1
Dim height As Integer = Bounds.Height - 1
g.DrawRectangle(mypen, 0, 0, width, height)
mypen.Dispose()
g.Dispose()
End If
End Sub

I hope it saves some of you some trouble

Tal McMahon
Jul 21 '05 #1
1 1242
While your approach probably will work....... accept the fact that your
also relaying on the call to the winAPI to also work... through unmanaged
code.......

Have you looked at inheriting the textbox (to define one of your own)...
and override the paint function ? I'm not even sure this would work on the
border...... but it might be there...... as the border is a property that
is set.... and must be painted .......

"Tal McMahon" <ta**@report-software.com> wrote in message
news:7e*************************@posting.google.co m...
After spending a morning wading through all the the Wrong answers and
responses I have figured out how to change the border on a textbox.

Here is the code:

Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal
hwnd As Integer, ByVal hdc As Integer) As Integer
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Const WM_PAINTBKG As Integer = 15
If m.Msg = WM_PAINTBKG Then
Dim g As Graphics = Me.CreateGraphics
Dim mypen As Pen = New
Pen(System.Drawing.SystemColors.GrayText, 1)
Dim width As Integer = Bounds.Width - 1
Dim height As Integer = Bounds.Height - 1
g.DrawRectangle(mypen, 0, 0, width, height)
mypen.Dispose()
g.Dispose()
End If
End Sub

I hope it saves some of you some trouble

Tal McMahon

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alien | last post by:
I have a hex editor-type class that extends UserControl and paints its data to a PictureBox. Basically the problem is that repainting it takes usually between 60 and 80ms, which may seem pretty...
2
by: Robert Misiak | last post by:
Hi everyone- I've done a lot of searching around on the web and I'm sure the answer to this question is no, but I'll ask anyway. Is it possible to create an inherited MonthCalendar control and...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
1
by: Tal McMahon | last post by:
After spending a morning wading through all the the Wrong answers and responses I have figured out how to change the border on a textbox. Here is the code: Declare Function ReleaseDC Lib...
3
by: Dave | last post by:
Hey all, Ok, here's another of my fun questions. I want to rewrite the textbox control in VB.NET. I need to implement superscript and subscript within the box. Don't ask why, but I can't use...
8
by: Filipe Marcelino | last post by:
Hi, I'm trying to create a textbox inheriting from the standard textbox. I would like to: 1. repaint the textbox border; 2. define a color for that border; Till now I made this:
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
4
by: H-S | last post by:
Please help. This is a real puzzler! Originally posted on microsoft.public.dotnet.framework.windowsforms but no answer found! I have a read-only textBox which shows the results of a selection...
1
by: =?Utf-8?B?RmxvcmlhbiBLb3dhbHNreQ==?= | last post by:
I need to paint a rectangle in above the textbox of a combobox. How can i do that. At present the rectangle is always in the background and the textbox is in the foreground!! Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.