Jump to content
  • Advertisement
Sign in to follow this  
020644

[.net] windows form properties in visual studio... :(

This topic is 4078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to get a multiline textbox to take up the entire client area of a window. Is there any way to do this using visual studio's property panel, or does it have to be done in code?

Share this post


Link to post
Share on other sites
Advertisement
Set the Dock property of the textbox to Fill (it's the center button in the property drop down). It's under the Layout category in the properties pane.

Share this post


Link to post
Share on other sites
instead of making a new thread...

i want to edit a single line in a textbox. do i have to copy the entire contents in order to do this? msdn says:

Quote:
To get a writable collection of lines, use code similar to the following: textBox1.Lines = new string[] { "abcd" };


what does that mean?

Share this post


Link to post
Share on other sites
Quote:
Original post by 020644
instead of making a new thread...

i want to edit a single line in a textbox. do i have to copy the entire contents in order to do this? msdn says:

Quote:
To get a writable collection of lines, use code similar to the following: textBox1.Lines = new string[] { "abcd" };


what does that mean?


Are you trying to get the line or change the line?


string a = textBox1.Lines[0]; // that will get the first line from the text box.
a = a.ToUpper(); // change the string to all Upper case.
textBox1.Lines[0] = a; // set first line equal to the Upper case string.


///////////////////////////////////////////////////////////////////
// if you want to get all the lines from the text box...
string[] lines = textBox1.Lines; // get all the lines from the text box.
foreach(string line in lines)
{
line = line.ToUpper(); // Set all the lines to upper case
}

textBox1.Lines = lines; //Set the textbox lines to lines[]



Does that help?
theTroll

Share this post


Link to post
Share on other sites
well, i'm trying to implement auto-indent using a textbox. it's incredibly difficult, however, because the newline character is added after i catch the keypress event for 'enter'.

even if i ever get it working, i'm only editing one line at a time in the textbox. it seems like a waste to copy the entire contents of the file each time the user presses enter. the quote from msdn above indicates that it's possible to get a mutable list of lines.

Share this post


Link to post
Share on other sites
I only skimmed over this thread, but an alternative might be to use the Textbox.Paste(string) method. This allows you to insert stuff at the cursor position, which may be more efficient and/or elegant. There's probably a way to cancel/consume the key event, so you could use this method to manually insert "\r\n\t\t" or something instead of allowing the textbox to add the enter. This page seems to contain more details on how to cancel the event (last reply at the bottom).

Hope this is what you were looking for :)

Share this post


Link to post
Share on other sites
thanks for your help, unfortunately there is no 'handled' property for PreviewKeyDownEventArgs!

how can i prevent the newline from being added automaticall?

edit: textbox.suppresskeypress works! i hope this can help someone else with the same problem. thanks for your help everyone.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!