![]() |
Inserting text into a textbox
Just fooling around with a simple Windows program. What I'm trying to do is when the user presses a button, a line of text saying "Hello There!" will display in a textbox above the button he just clicked. Here's what I got so far but it's not working:
:
private void button1_Click(object sender, EventArgs e)I've tried lots of different ways to get the text to display in the textbox, but every way fails. |
:
|
Ah, I figured out a solution. I failed to create a variable of type string:
:
string text = "Hello There!";Now it works. But could you tell me why when I'm in the design mode I can't move my form on the screen? It seems locked in one spot, and the Locked Property is already set to false. |
It is located because the form is just the form, its position on the screen can be changed using a property of the form.
Basically, it is just there in the middle cause it is easy to edit there. Look for the property 'StarPostion' and change that to get your form to start in a new position. Hope that helps. |
Yeah, when I change the property to center screen the form does move to the center during runtime. But it seems to me that I should also be able to have the form where I want it during design time. And I can't change it. Can't move it at all. Its locked over to the left side of the screen. I'd rather have the form in the center of the screen even when I'm in design mode and adding controls to it.
|
Speak to the designers of your form editor.
|
Quote:
While this works it is by no means necessary. You do not need to have a variable on the right hand side of your assignment operator. A string literal will work just fine. like so: :
textBox1.Text = "Hello There!";also, I do not understand why you would want to move the form position in the designer? |
If you want to center it, you can change the width of the solution explorer, and toolbox so it's bigger. it will center your form, but it's a pretty big waste of space. I think your code view will be cut down as well though.
|
Sadly I dont think there is enough demand for what you are asking 357mag. And should it really matter if it is in the middle of the screen or not? It is a relative object and it should matter in my opinion.
Booooze you are correct, you can center it by adjusting the widths of your side tool bars, but you would loose the code area. |
| All times are GMT -5. The time now is 2:09 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC