TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
don t
NA
3
6.1k
How to pass the data of my selection from SubForm to the MainForm
Sep 20 2012 7:25 PM
I have two forms. MainForm and SubForm. SubForm has a combobox. Select button on MainForm and the SubForm opens. I select one of the options on the combobox click ok button and SubForm closes. I want to pass the data of my selection to the MainForm. I know this is simple but I keep messing it up somehow. Please show code with help thanks.
MainForm code is
string newrecordtype = null;
formSubForm newSubForm = new formSubForm(newrecordtype);
newSubForm.ShowDialog();
MessageBox.Show(newrecordtype.ToString());
SubForm code is
public
partial
class
FormNewRecordTypeSelection
:
Form
{
public
string
newrecordtype =
null
;
public
FormNewRecordTypeSelection(newrecordtype)
{
InitializeComponent();
}
public
void
buttonOK_Click(
object
sender,
EventArgs
e)
{
object
selectedIndex = comboBox1.SelectedIndex;
Object
selectedItem = comboBox1.SelectedItem;
MessageBox
.Show(
"Selected Item Text: "
+ selectedItem.ToString() +
"\n"
+
"Index: "
+ selectedIndex.ToString()); newrecordtype = selectedItem.ToString();
}
Reply
Answers (
2
)
Convert C# to C++ help ?
Perform function on numbers?