group of buttons
-
Hi, I have a project with 2 groups of buttons and I need assign to event on click to 1 group same piece of code and to 2 group another code. Solving it some component like GroupBox or someone?
The other answer posted to this thread will work perfectly. Another option would be to create a new usercontrol for the groupbox control collection.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios Discounted or Free Software for Students: DreamSpark - downloads.channel8.msdn.com MSDN Academic Alliance - www.msdnaa.com
-
Hi, you can use the same Click handler for more than one Control. And if need be, cast sender to the right Control type to find out which Control fired the Click event. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
Can you write that in code please? I need something like this to more powerful code: NOW: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { } ... Future something like this: button 1-10_Click
-
Can you write that in code please? I need something like this to more powerful code: NOW: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { } ... Future something like this: button 1-10_Click
replace button2_Click by button1_Click everywhere; replace button3_Click by button1_Click everywhere; replace button4_Click by button1_Click everywhere; replace button5_Click by button1_Click everywhere; replace button6_Click by button1_Click everywhere; replace button7_Click by button1_Click everywhere; replace button8_Click by button1_Click everywhere; replace button9_Click by button1_Click everywhere; replace button10_Click by button1_Click everywhere; everywhere also includes code autogenerated by Visual Studio. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
replace button2_Click by button1_Click everywhere; replace button3_Click by button1_Click everywhere; replace button4_Click by button1_Click everywhere; replace button5_Click by button1_Click everywhere; replace button6_Click by button1_Click everywhere; replace button7_Click by button1_Click everywhere; replace button8_Click by button1_Click everywhere; replace button9_Click by button1_Click everywhere; replace button10_Click by button1_Click everywhere; everywhere also includes code autogenerated by Visual Studio. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
Thank you, it works. But I have got still one little problem. I need take Button1->Text, ..., Button10->Text so I have something like that private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->AppendText(
buttonX
->Text); } How to change X? -
Thank you, it works. But I have got still one little problem. I need take Button1->Text, ..., Button10->Text so I have something like that private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->AppendText(
buttonX
->Text); } How to change X?Hi, as I told you before, you can cast sender to the right Control type to find out which Control fired the Click event. In your case, cast to Button, then use its Text property. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi, as I told you before, you can cast sender to the right Control type to find out which Control fired the Click event. In your case, cast to Button, then use its Text property. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
can you write it in code please?
-
can you write it in code please?
if you show your code, and specify its symptoms, CP members will help and pinpoint the problem(s). :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
if you show your code, and specify its symptoms, CP members will help and pinpoint the problem(s). :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->AppendText(System::Windows::Forms::ButtonBase::Text); } I do this code, but it still needs System::Windows::Forms::ButtonBase::Text as a static. I think I follow your definition - you can say that in values sender and e is everything what can we need.
-
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { textBox1->AppendText(System::Windows::Forms::ButtonBase::Text); } I do this code, but it still needs System::Windows::Forms::ButtonBase::Text as a static. I think I follow your definition - you can say that in values sender and e is everything what can we need.
you still need to take "sender", cast it to a Button and take its Text. :(
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
you still need to take "sender", cast it to a Button and take its Text. :(
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
textBox1->AppendText(this->ActiveControl->Text); Yipee! Fairness still exists :) Thank you so much
modified on Sunday, July 6, 2008 4:40 PM