472,780 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 2734
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
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
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
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
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
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
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
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
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
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
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.