Click here to Skip to main content
12,064,615 members (24,723 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: .NET3.5 C# .NET selection , +
Hi,

I created dataGridView with 3 column connected using Linq to Sql. The all 3 columns are defined like dataGridViewTextColumn.

- - - - - - - - - - - - - - - - - - - - - - -'
First Name ' Last Name ' ---Date----' - Headers
-----------'-----------'--------------'
---John--- '--Green--'01.01.2013-- ' - Data
---Phil--- '--Muray---'02.01.2013--'
- - - - - - '- - - - - '- - - - - - - - - - - '

My problem is when I click one row from the dataGridView from windows form "Form1" to fill with data all 3 Textboxes(FirstNameTextbox, LastNameTextBox, DateTextBox) from windows form "Form2".
I'm using CellContentClick method but I don't have idea how to solve this problem.

<pre lang="cs">private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
           if (dataGridView1.CurrentCell.Value != null)
           {
                Form2 f2 = new Form2();
                f2.Show();
                ... no idea...
           }
        }</pre>
 
Thanks in advanced for your help.
Posted 26-Feb-13 2:30am
zabamkd463
Edited 26-Feb-13 2:36am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Create 3 properties in Form2 and create a parametrized constructor which will fill the value when you create the object of the Form2, or you can directly assign the value to TextBoxes in constructor.

Form2:

public Form2(string _firstName, string _lastName, DateTime _date)
        {
            InitializeComponent();
            textBox1.Text = _firstName;
            textBox2.Text = _lastName;
            textBox3.Text = _date.ToShortDateString();
        }


Form1:

Form2 frm = new Form2("first", "second", System.DateTime.Now);
            frm.Show();
  Permalink  
Comments
zabamkd 26-Feb-13 12:04pm
   
Thanks for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160204.4 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100