Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody.
I need to past number of button to textBox.
Step
1) Select textBox. , now Cursor focus textBox.
2) Click any button, Text of button past to textBox.
but i have no idea how to...
please give me good idea.
I need like this See Image
Posted
Updated 2-Feb-15 5:43am
v7
Comments
ZurdoDev 2-Feb-15 10:57am    
I don't understand your question.
terzasek 2-Feb-15 11:44am    
Sorry. Improve my question.
ZurdoDev 2-Feb-15 11:47am    
Do you know much at all about programming? Each button will have a click event, and in that event you set the textbox value.

Where exactly are you stuck?
terzasek 2-Feb-15 12:08pm    
I know Each button will have a click event.
But i have 100 textBox, i need to past number to textBox select.
King Fisher 2-Feb-15 11:04am    
like a calculator program?

The thing can be, to write the Text property of the Button inside the TextBox, or append the text to it.

Take the following scenario as example,

C#
// Create button and write 2 to it; just as example
Button button = new Button();
button.Text = "2";

// To handle event, 
button.Click += Button_Click;

// Create a new instance of TextBox
TextBox textBox = new TextBox();


Now upon click, you can handle the event and write its value to the TextBox. Like this

C#
void Button_Click(object sender, EventArgs e) {
   // The object that raised this event was Button so change it 
   Button button = sender as Button;
   string value = button.Text; // would be '2'
   // assign (append; see the +=) this value to the TextBox
   textBox.Text += value;
}


This is a very basic example of this project and scenario, for a simple example of this I had a project for the Calculator application, you can view that application to understand this pattern, get the source code for that at https://code.msdn.microsoft.com/Simple-Calculator-34e18835[^]
 
Share this answer
 
Comments
terzasek 2-Feb-15 12:27pm    
sorry i'm a beginner i can't work, and

// Create button and write 2 to it; just as example
Button button = new Button();
button.Text = "2";

// To handle event,
button.Click += Button_Click;

// Create a new instance of TextBox
TextBox textBox = new TextBox();

where to take the code?
Interesting one terzasek.

You can use Mouse_Down event of the text boxes. You can take a global variable or a label to hold the value of the mouse down on which textbox. and after button click get the value from label(ie. whcih textbox has been selected) and do your necessary work or calculations . I have done a small example to do this as you describe in the image in your question. just take a look on this. I hope your confusion will be cleared after checking the example.
Example :
https://app.box.com/s/iedkdaraa1uts4n43l31hlwvf5cp30d6[^]
 
Share this answer
 
Comments
terzasek 2-Feb-15 12:09pm    
Thank you it's work.
Arkadeep De 2-Feb-15 12:12pm    
u welcome
terzasek 2-Feb-15 12:33pm    
Just one!
I have 100 textBox. I'm looking for the best way,
if it Possible.
Arkadeep De 2-Feb-15 13:01pm    
http://stackoverflow.com/questions/3898588/find-control-by-name-from-windows-forms-controls?answertab=active#tab-top

On mouse_down set the id of the Text Box in a label and find it by name in button click and change it or do whatever..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900