473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override the Textbox - question

hi,

i read in the web about how can i change the foreColor of a textBox when
it's set to enabled=false or readonly, and that what was written:

public MyTextBox()
{ // This call is required by the Windows.Forms Form Designer.

this.SetStyle(ControlStyles.UserPaint,true);
}
protected override void OnPaint(PaintEventArgs e)

{

SolidBrush drawBrush = new SolidBrush(Color.Blue); //Use the ForeColor
property

// Draw string to screen.
int sizes=this.Size.Width;
e.Graphics.DrawString(Text, new System.Drawing.Font("Microsoft Sans Serif",
8.5f, System.Drawing.FontStyle.Bold), drawBrush,0f,0f); //Use the Font
property

}

now my problem is that sometimes i need the text to be wrriten from right To
left and sometimes from left to write, i tried to change the alligment and
the rightToleft property but still the point(0,0) stays always from the left
side.

and my textbox sizes are different so i can i make it to write my text form
the right point of the text box to the left?

thanks

Nov 16 '05 #1
3 2758
Use StringFormatFlags.DirectionRightToLeft in your call to DrawString

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
"Gidi" <sh*****@hotmail.com.dontspam> wrote in message
news:9E**********************************@microsof t.com...
hi,

i read in the web about how can i change the foreColor of a textBox when
it's set to enabled=false or readonly, and that what was written:

public MyTextBox()
{ // This call is required by the Windows.Forms Form Designer.

this.SetStyle(ControlStyles.UserPaint,true);
}
protected override void OnPaint(PaintEventArgs e)

{

SolidBrush drawBrush = new SolidBrush(Color.Blue); //Use the ForeColor
property

// Draw string to screen.
int sizes=this.Size.Width;
e.Graphics.DrawString(Text, new System.Drawing.Font("Microsoft Sans Serif", 8.5f, System.Drawing.FontStyle.Bold), drawBrush,0f,0f); //Use the Font
property

}

now my problem is that sometimes i need the text to be wrriten from right To left and sometimes from left to write, i tried to change the alligment and
the rightToleft property but still the point(0,0) stays always from the left side.

and my textbox sizes are different so i can i make it to write my text form the right point of the text box to the left?

thanks

Nov 16 '05 #2
hi joseph,

i did it, but it doesn't help, still the 0,0 point is on the left side.
what i need to know is how can i know what is right point.

thanks

"Sijin Joseph" wrote:
Use StringFormatFlags.DirectionRightToLeft in your call to DrawString

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
"Gidi" <sh*****@hotmail.com.dontspam> wrote in message
news:9E**********************************@microsof t.com...
hi,

i read in the web about how can i change the foreColor of a textBox when
it's set to enabled=false or readonly, and that what was written:

public MyTextBox()
{ // This call is required by the Windows.Forms Form Designer.

this.SetStyle(ControlStyles.UserPaint,true);
}
protected override void OnPaint(PaintEventArgs e)

{

SolidBrush drawBrush = new SolidBrush(Color.Blue); //Use the ForeColor
property

// Draw string to screen.
int sizes=this.Size.Width;
e.Graphics.DrawString(Text, new System.Drawing.Font("Microsoft Sans

Serif",
8.5f, System.Drawing.FontStyle.Bold), drawBrush,0f,0f); //Use the Font
property

}

now my problem is that sometimes i need the text to be wrriten from right

To
left and sometimes from left to write, i tried to change the alligment and
the rightToleft property but still the point(0,0) stays always from the

left
side.

and my textbox sizes are different so i can i make it to write my text

form
the right point of the text box to the left?

thanks


Nov 16 '05 #3
Thanks i found the answer...
Nov 16 '05 #4

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

Similar topics

11
19433
by: z_learning_tester | last post by:
Hello, yes another beginner question that I'm sure is obvious to many here :-) My book is so bad. Really. It uses the exact same example of code for using the new kw and for using virtual(in the...
1
2137
by: Paul E Collins | last post by:
I am writing a class that inherits from TextBox. My class, UndoTextBox, extends the standard control by enabling multi-level undo and redo operations. Annoyingly, some of the affected properties...
8
11784
by: Keith Smith | last post by:
Could some one help me a little? I am trying to understand when/where you would ever want to use "protected override..." code such as this. How is this any different from creating a...
3
4224
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
4
1952
by: John Smith | last post by:
Hi All; I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have customized it for a wider row. I reposition the DrawString method so the text is centered vertically in the row. ...
2
4457
by: =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?= | last post by:
HI there. I use IE7. We have a user with bad eyesight. he cannot read the font when IE makes an input disabled (the light grey color font). I am able to change the background to a different color...
1
3070
by: Joshua | last post by:
I'm creating a web control that has an image and a text box. I would like to then override the Visible and Text property of the usercontrol, so when you reference the visible property of the user...
3
1636
by: Cylix | last post by:
I would like to rewrite the textbox.click event. But I cannot find the correct stuff on this matter, is it call override? Please give me some hints, Thanks!
2
6241
by: Jason Huang | last post by:
Hi, How do I override a TextBox's KeyPress evnt? And how do we use it? Thanks for help. Jason
0
7231
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
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.