Setting up Text Boxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Morey

    Setting up Text Boxes

    I have a Text Box in my program that takes user input , it has multiline set
    to true , and will automatically clear the text box when the enter key is
    pressed (after passing it to another "engine" class to do some processing
    with) , however when the box is cleared with either the Clear() method OR by
    setting Text = "" the cursor position will not return to the start of the
    box , leaving the user to do this manually which is obviously not ideal.

    Another part of my form displays output from the "engine" class , this is
    rendered in a textbox , however i do not want the user to be able to type
    into this textbox , so I set ReadOnly = true , however this makes the
    background to the box white where it would fit in with the look and feel of
    the application to have it white and it doesnt seem to let me change it....

    Im using Visual Studio 2002 Pro (if that makes any difference)

    Ideas anybody?


  • MHelland

    #2
    Re: Setting up Text Boxes

    > however when the box is cleared with either the Clear() method OR by[color=blue]
    > setting Text = "" the cursor position will not return to the start of the
    > box , leaving the user to do this manually which is obviously not ideal.[/color]

    You can use the Select() method of the textBox:
    textBox1.Select (0, 0);

    or the Selection* properties to do the same thing.
    [color=blue]
    > into this textbox , so I set ReadOnly = true , however this makes the
    > background to the box white where it would fit in with the look and feel[/color]
    of[color=blue]
    > the application to have it white and it doesnt seem to let me change[/color]
    it....

    But it is consistent with the look and feel of Windows, which is more
    important.

    To work around this (if you must), just set the BackColor to white:
    textBox1.ReadOn ly = true;
    textBox1.BackCo lor = Color.White;


    Comment

    Working...