Textbox text isn't updating

T

trint

I have a textbox (textBox7) that isn't updating..
Is there a way, after I type new text in it, to have it update?
It seems to be fairly normal:

public class Form1
: System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox7;
......
private void InitializeComponent()
{
this.textBox7 = new System.Windows.Forms.TextBox();

// textBox7
//
this.textBox7.Location = new System.Drawing.Point(248, 32);
this.textBox7.Name = "textBox7";
this.textBox7.Size = new System.Drawing.Size(72, 20);
this.textBox7.TabIndex = 69;
this.textBox7.Text = "";
//
this.Controls.Add(this.textBox7);


Ok, the Form1 is idol and I type "100".

then debug and watch here:
public void getTextBox7()
{
Form1 this2watch = new Form1();
string addwatch = this.textBox7.Text;<<<Nothing is in here!
Class1.watCHTimer1 = Convert.ToInt16(addwatch);
}

thanks in advance,
Trint



Thanks,
Trint
 
D

Dan Bass

you type in the text, and click a button to get into this procedure?
If not, when getTextBox7() being called?
 
T

Trint Smith

I just put a value in the textbox and run a function that is supposed to
get the text from the box and assign it to a string. That's it. And
there is nothing in it.
trint

..Net programmer
(e-mail address removed)
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Who/ Where call getTextBox7() ?

do you mean that even if you type something in you do not see it on the
screen?

Please give more details

cheers,
 
T

trint

Ok,
This is where it is called:
From Class1.cs:

public static void testwatcher()
{
Form1 finDWatchInt = new Form1();
do
{
finDWatchInt.getTextBox7(); <<This is the call.
watCHTimer1 = Convert.ToInt16(finDWatchInt.textBox6.Text);
MessageBox.Show("Please enter a number value!");
}
while(watCHTimer1 < 1);
}

Thanks,
Trint
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

There are a number of thing I do not get from your code,

Why testwatcher is static?

You are not even showing the form in the first place, how do you expect it
to have a value?

Form1 finDWatchInt = new Form1();
do
{
finDWatchInt.ShowDialog(); // ********* include this line
finDWatchInt.getTextBox7(); <<This is the call.
watCHTimer1 = Convert.ToInt16(finDWatchInt.textBox6.Text);
MessageBox.Show("Please enter a number value!");
}
while(watCHTimer1 < 1);
}

still I do not understand what you are trying to do.


cheers,
 
T

trint

Ignacio,
I can't do a "finDWatchInt.ShowDialog(); because the Form1 is already
showing (Form1 would then appear twice???). This happens as a result
of this button click:

public void button19_Click(object sender, System.EventArgs e)
{
Class1.testwatcher();
}
Thanks,
Trint
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Trinit,


Just by creating a form it does not show it in the screen, unless you call
Show() on it.

You are creating a new instance of Form1:

public static void testwatcher()
{
Form1 finDWatchInt = new Form1();

so this instance is not being displayed in the screen, unless you call Show


Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top