You can achieve this with the help of custom event handler class:-
In Form2:-
1). Define a customeventhandler event like:-
public static event System.EventHandler CustomerEventHandler;
2). Store the selected item from the listbox into a static variable like :-
Public static string strListItem=string.Empty();
strListItem=lstBox.selectedValue.ToString()
3).Then on the SelectedValueChanged event of the ListBox:-
if (CustomerEventHandler != null)
{
CustomerEventHandler(sender, e);
}
In Form1:-
1).add the is code on the page load:-
frmCustomer c = new frmCustomer();
c.CustomerEventHandler += new EventHandler(ShowListItemInGrid);
2). Define the method bind to custom event handler in this way:-
private void ShowListItemInGrid(object sender,eventargs e)
{
....
...
}
Please refer this link if you face some problem in this code:-
http://www.codeproject.com/Articles/34454/Pass-Data-from-One-Form-to-Another-Form[
^]
Creating advanced C# custom events[
^]
Please don't forget to mark this as your answer if it helps you out.
Thanks