CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Posts
    1

    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.

  2. #2
    Join Date
    Jul 2007
    Location
    In the present
    Posts
    80

    Smile 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
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured