Action of a button to a text box?

B

Byaghy

Hi,
I'm quite a newbie with c# and would like to know how to pass a result
to a text-box. Forexample I have a simple form with few textboxes and
a button. When the button is clicked a function calculates something
and the result appears into one of the forms textboxes. How do I do
that?
 
R

RayLopez99

Hi,
I'm quite a newbie with c# and would like to know how to pass a result
to a text-box. Forexample I have a simple form with few textboxes and
a button. When the button is clicked a function calculates something
and the result appears into one of the forms textboxes. How do I do
that?

The textbox has a property, I think it's called ".name".

So, at the button event handler (I trust you know what that is), you
enter a line

TheNameOfYourTextBoxHere.name = "stringFromTheFunction"; //this will
allow your textbox to show the string. You can do the same with a
Label.

You can convert a number to a string any number of ways, such
as .ToString() extension for example.

Doing this from memory, but I think I'm 75% correct or greater.

RL
 
J

Jeff Johnson

I'm quite a newbie with c# and would like to know how to pass a result
to a text-box. Forexample I have a simple form with few textboxes and
a button. When the button is clicked a function calculates something
and the result appears into one of the forms textboxes. How do I do
that?

Although you're using C#, your question is actually about Windows Forms. I
recommend you ask future questions (since it sounds like you're a complete
beginner with WinForms and are probably focusing on that) in
microsoft.public.dotnet.framework.windowsforms or one of its subgroups.
 
P

proxyuser

Jeff Johnson said:
Although you're using C#, your question is actually about Windows Forms. I
recommend you ask future questions (since it sounds like you're a complete
beginner with WinForms and are probably focusing on that) in
microsoft.public.dotnet.framework.windowsforms or one of its subgroups.

such as microsoft.public.dotnet.framework.windowsforms.controls, possibly
 
P

proxyuser

The textbox has a property, I think it's called ".name".
TheNameOfYourTextBoxHere.name = "stringFromTheFunction"; //this will
allow your textbox to show the string. You can do the same with a
Label.

The text box has a property called Name (not .name), and you definitely
don't want to use that property
Doing this from memory, but I think I'm 75% correct or greater.

There is little sense in posting things you don't know. It will just spread
confusion. If you don't know, and you're not willing to try the code first,
then just pass on answering the question.
 
P

proxyuser

Byaghy said:
Hi,
I'm quite a newbie with c# and would like to know how to pass a result
to a text-box. Forexample I have a simple form with few textboxes and
a button. When the button is clicked a function calculates something
and the result appears into one of the forms textboxes. How do I do
that?

In the designer where you lay out your form, select the button. Double
click on it. The designer will automatically insert an event for the button
click and take you to the code (a method such as button1_Click()). From
there, you can write code such as

textbox1.Text = "new text";
 
R

RayLopez99

"RayLopez99" <[email protected]> wrote in message
There is little sense in posting things you don't know. It will just spread
confusion. If you don't know, and you're not willing to try the code first,
then just pass on answering the question.

I disagree. Even an incomplete answer is better than no answer.

RL
 

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