C# Datagrid - Open new form.
I have a application that I am working on that returns search results to a Datagrid. What I would like to do is when the user clicks on the info line they want have it open another form with only that data populating the new form. For example, the click on the vendor record for Vendor No: 1234, a form will open for Vendor 1234 with more detailed info, not a datagrid but a UI thats more user friendly. I think I will need to have a query that will run upon load with the vendor number being passed from the datagrid.
Re: C# Datagrid - Open new form.
Try something like this
Code:
private void mouseDoubleClick_Click(object sender, EventArgs e)
{
string vendorID = //get this info from your datagrid or dataset
//Add a new form to your project
NewForm myForm = new NewForm(vendorID);
myForm.Text = "Vendor infor";
myForm.Show();
}
On the new form you set it to accept a string
Code:
public ContactForm(string vendorID)
{
InitializeComponent();
GetContactInformation(vendorID);
}
private void GetVendorInformation(string id)
{
//query the db and load this form
}