Jump to content
Sign in to follow this  
Info

Need some help with GUI Controls in C#

Recommended Posts

Info

Okay, three questions:

1. How do I make a richTextBox to read-only...?

2. I know that to insert a text to a control I need to:

this.richTextBox1.Text = "new text";

But how do I make new lines? (@CRLF in AutoIt)

3. How do I insert the green lines in the progress bar? (GUICtrlSetData ($Progress, 50) in AutoIt)

Thanks :)

Share this post


Link to post
Share on other sites
monoceres

After a quick google search it turns out that System.Enviroment.NewLine is a newline in C#

:)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
Richard Robertson

C# uses many of the same escape codes as C++. You would use the character '\n' to do a newline. '\r' is a carriage return.

Share this post


Link to post
Share on other sites
monoceres

Again, I do not program in C#, but I believe this.richtextBox1.Locked=true will make the richtext readonly :)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
Richard Robertson

Text controls in .Net have a property very obviously labeled as "ReadOnly". If you are using a standard .Net control, try looking for ReadOnly.

Share this post


Link to post
Share on other sites
cppman

Progress bars have a property called Value. You set the Minimum and Maximum values also.

So if the Minimum is 0 and the Maximum is 100, and the Value is 50, you'll have a 50% filled progress bar. :)

Share this post


Link to post
Share on other sites
jhunt1

Are you wanting to have multiple lines of text from a single string, or add a new line to text that's already in the RichTextBox?

If you are wanting to have multiple lines of text from a single string, you can use the System.Enviroment.NewLine, or a simple "\n".

this.richTextBox1.Text = "new\ntext";

This example puts "new" on one line, and "text" on a new line.

To add new text to a RichTextBox, you can use the AppendText() method.

this.richTextBox1.AppendText("new text");

Note: If using AppendText(), and you want it to be on a new line, you need to add a "\n" to the beginning of the string:

this.richTextBox1.AppendText("\nnew text");
Edited by jhunt1

Share this post


Link to post
Share on other sites
jhunt1

And one more thing, to make it readonly........

this.richTextBox1.ReadOnly = true;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.