igor92128
asked on
Writing a ListBox value to another Form
I'am trying to write the current selected value in a listBox to another form. Here is the code so far:
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ListB ox mainList;
private UpdateStudent _updateForm;
.....
private void btnUpdate_Click(object sender, System.EventArgs e)
{
this._updateForm = new UpdateStudent();
_updateForm.ShowDialog();
this._updateForm.stuName.T ext = mainList.SelectedItem.ToSt ring();
}
It is trying to set the stuName text in the updateform to the currently selected Item in the mainList listbox. However, when I access the _updateForm, stuName is empty. Why is it not being populated with the text of the currently selected line in the listbox? Also, it compiles fine.
Thanks.
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.ListB
private UpdateStudent _updateForm;
.....
private void btnUpdate_Click(object sender, System.EventArgs e)
{
this._updateForm = new UpdateStudent();
_updateForm.ShowDialog();
this._updateForm.stuName.T
}
It is trying to set the stuName text in the updateform to the currently selected Item in the mainList listbox. However, when I access the _updateForm, stuName is empty. Why is it not being populated with the text of the currently selected line in the listbox? Also, it compiles fine.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.