problem transfering data from one form to another

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 3
Reputation: roachae is an unknown quantity at this point 
Solved Threads: 0
roachae's Avatar
roachae roachae is offline Offline
Newbie Poster

problem transfering data from one form to another

 
0
  #1
Apr 9th, 2009
I have two Windows forms. Form1 has a button which, when clicked on, opens up Form2 (which looks like a drop down/combobox type of control). Form2 is a grid of buttons that look like a telephone keypad. When one of these buttons is clicked on, Form2 closes and the text that was on the button clicked should be set to the text of the button in Form1. Anyone have any idea how I can do this? I've tried some code samples that sends text from a textbox from one form to another, but nothings working for the buttons I'm using. Form2 closes as it should when one of it's buttons is clicked... I just can't figure out how to send that buttons text to Form1's button's text.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: problem transfering data from one form to another

 
0
  #2
Apr 9th, 2009
Look, As far I got your scenario, Form2 may have property Number which holds the numbers user enters.
Before closing the Form2 From Form1, read the Form2.Number.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: problem transfering data from one form to another

 
0
  #3
Apr 9th, 2009
here's a link on a small little sample i did for that

http://alleratech.com/blog/post/Shar...ms-with-C.aspx
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 3
Reputation: roachae is an unknown quantity at this point 
Solved Threads: 0
roachae's Avatar
roachae roachae is offline Offline
Newbie Poster

Re: problem transfering data from one form to another

 
0
  #4
Apr 9th, 2009
Here's a screen capture of what I've got to give a better idea of what it is I'm trying to do. No textboxes are involved at all. Only buttons and the text on those buttons. The "telephone keypad" is my Form2, which "pops up" (or, "drops down", as it appears to do in my app) when the "?" button on my Form1 is clicked on. Form2 has no titlebar or border to give it the appearance of a "drop down" control. When one of the number buttons on Form2 is clicked on, the keypad (Form2) closes, but whatever key is clicked on, that number, "*" or "#" should replace the "?" text in the button on Form1.
Attached Thumbnails
sendButtonText.JPG  
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: problem transfering data from one form to another

 
0
  #5
Apr 9th, 2009
whether it is buttons or textboxes, still the same concept

  1. //form 1
  2. frmKeypad frmKey = new frmKeypad();
  3. frmKey.ShowDialog();
  4. this.btnQuestion.Text = frmKey.SelectedKey;
  5.  
  6.  
  7. //form 2
  8. private string selectedKey;
  9. public string SelectedKey
  10. {
  11. get{ return selectedKey; }
  12. }
  13.  
  14. //sample with just one button
  15. private void btnOne_Click(object sender, EventArgs e)
  16. {
  17. this.selectedKey = "1";
  18. }

you can get creative with this and use a more generic method of doing this, but those are the basics
Last edited by dickersonka; Apr 9th, 2009 at 9:25 pm.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC