Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 at 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
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2014
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