943,671 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 2359
  • C# RSS
Apr 9th, 2009
0

problem transfering data from one form to another

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
roachae is offline Offline
60 posts
since Apr 2009
Apr 9th, 2009
0

Re: problem transfering data from one form to another

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.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Apr 9th, 2009
0

Re: problem transfering data from one form to another

here's a link on a small little sample i did for that

http://alleratech.com/blog/post/Shar...ms-with-C.aspx
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Apr 9th, 2009
0

Re: problem transfering data from one form to another

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
Click image for larger version

Name:	sendButtonText.JPG
Views:	443
Size:	7.5 KB
ID:	9741  
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
roachae is offline Offline
60 posts
since Apr 2009
Apr 9th, 2009
0

Re: problem transfering data from one form to another

whether it is buttons or textboxes, still the same concept

C# Syntax (Toggle Plain Text)
  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.
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Navigate between records in C#
Next Thread in C# Forum Timeline: Label not updating





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC