| | |
problem transfering data from one form to another
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
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.
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.
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
here's a link on a small little sample i did for that
http://alleratech.com/blog/post/Shar...ms-with-C.aspx
http://alleratech.com/blog/post/Shar...ms-with-C.aspx
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
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.
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
whether it is buttons or textboxes, still the same concept
you can get creative with this and use a more generic method of doing this, but those are the basics
C# Syntax (Toggle Plain Text)
//form 1 frmKeypad frmKey = new frmKeypad(); frmKey.ShowDialog(); this.btnQuestion.Text = frmKey.SelectedKey; //form 2 private string selectedKey; public string SelectedKey { get{ return selectedKey; } } //sample with just one button private void btnOne_Click(object sender, EventArgs e) { this.selectedKey = "1"; }
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
www.houseshark.net
![]() |
Other Threads in the C# Forum
- Previous Thread: Navigate between records in C#
- Next Thread: Label not updating
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






