![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 148
Rep Power: 4
![]() |
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)
{
string = "Hello There!";
textBox1.Text.Insert(0,string);
}I've tried lots of different ways to get the text to display in the textbox, but every way fails. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jan 2005
Posts: 110
Rep Power: 4
![]() |
c# Syntax (Toggle Plain Text)
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 148
Rep Power: 4
![]() |
Ah, I figured out a solution. I failed to create a variable of type string:
string text = "Hello There!";
textBox1.Text = text;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. |
|
|
|
|
|
#4 |
|
Man Bear Pig Hunter
Join Date: Jul 2005
Location: NorCal, USA
Posts: 292
Rep Power: 4
![]() |
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.
__________________
People who click "images" that end with .exe shouldn't have computers. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 148
Rep Power: 4
![]() |
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.
|
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Speak to the designers of your form editor.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#7 | |
|
Hobbyist Programmer
|
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?
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
|
#8 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#9 |
|
Man Bear Pig Hunter
Join Date: Jul 2005
Location: NorCal, USA
Posts: 292
Rep Power: 4
![]() |
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.
__________________
People who click "images" that end with .exe shouldn't have computers. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OnlineTextEditor.Com! | Sane | Show Off Your Open Source Projects | 43 | Jun 16th, 2006 8:55 AM |
| Basic HTML Tutorial - Reuben Keeney | ReubenK | HTML / XHTML / CSS | 14 | Mar 26th, 2006 5:50 AM |
| How to detect cursor location and insert text??? | syntax-error | C# | 3 | Jun 30th, 2005 1:42 AM |
| inserting text into a string | woodywellhung | C++ | 5 | Feb 17th, 2005 4:06 PM |