Hi,

Environment : VS 2005 / .NET 2.0 / Windows XP SP2

Requirement :

class MyTextBox : TextBox
{
// more code

}


When I run the application my text box caret blinks in its usual place ( at
the left ).

I want the cursor to be X pixels from the left of the text box and hence
the user can only enter data from that location.

I tried with SelectionStart += X pixels -- it did not work

Then I pinvoke SetCaretPos(X, Y ) - showed up the caret position properly.

Problem :

Though the caret position shows up properly, when I type text within my text
box, the text is taken from the 0th location .

How can I force the user to enter data from the X th location where the
cursor is placed .

NOTE : I have handled OnPaint to do some graphics drawing inside the
textbox... dont think this has any relevance with this query ; just FYI if
something is linked up to this .

Thanks in advance .

Sujay








--
Sujay Ghosh
Bangalore, INDIA

Re: Textbox input from a customized location by Bob

Bob
Sat Feb 16 07:45:10 CST 2008

The textbox text will always start from the first position. You could
possibly place some dummy places into the textbox first.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


"Sujay Ghosh" <SujayGhosh@discussions.microsoft.com> wrote in message
news:7EDC5701-4C71-4BE7-AE54-E1E891507D0B@microsoft.com...
> Hi,
>
> Environment : VS 2005 / .NET 2.0 / Windows XP SP2
>
> Requirement :
>
> class MyTextBox : TextBox
> {
> // more code
>
> }
>
>
> When I run the application my text box caret blinks in its usual place (
> at
> the left ).
>
> I want the cursor to be X pixels from the left of the text box and hence
> the user can only enter data from that location.
>
> I tried with SelectionStart += X pixels -- it did not work
>
> Then I pinvoke SetCaretPos(X, Y ) - showed up the caret position properly.
>
> Problem :
>
> Though the caret position shows up properly, when I type text within my
> text
> box, the text is taken from the 0th location .
>
> How can I force the user to enter data from the X th location where the
> cursor is placed .
>
> NOTE : I have handled OnPaint to do some graphics drawing inside the
> textbox... dont think this has any relevance with this query ; just FYI if
> something is linked up to this .
>
> Thanks in advance .
>
> Sujay
>
>
>
>
>
>
>
>
> --
> Sujay Ghosh
> Bangalore, INDIA
>
>