| | |
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 array barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom cyclethruopenforms data database datagrid datagridview dataset date/time datetime degrees development dll draganddrop drawing encryption enum event excel file finalyearproject form format forms function gdi+ getoutlookcontactusinfcsvfile globalization httpwebrequest image index input install installer java label list listbox mandelbrot math mono mouseclick mysql operator panel path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox save server silverlight sleep socket sql sql-server statistics stream string table text textbox thread time timer timespan update usercontrol users validate validation visualstudio webbrowser wia windows winforms wpf xml






