This is a migrated thread and some comments may be shown as answers.

Gridview retrieve identity in new window

2 Answers 42 Views
GridView
This is a migrated thread and some comments may be shown as answers.
dbernett
Top achievements
Rank 2
dbernett asked on 19 Oct 2012, 05:39 PM
Brand new to winforms GridView.  First Day. Been using ASP.NET Gridview for years.

Easy question I hope. 

How do you "double click" on a row, open a new window, pass Identity ID to... so I can retreive information details?

private void radGridView1_DoubleClick(object sender, EventArgs e)
        {
            DetailsForm form = new DetailsForm();
            form.Show();
        }


Thank you.

2 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 22 Oct 2012, 02:52 PM
Hello David,

Thank you for writing.

In winforms, you should pass the desired values as parameter of the form constructor or set it to form's property. I recommend creating the DetailsForm in the following manner: 
public partial class DetailsForm : Form
{
    private int id;
 
    public DetailsForm()
    {
        InitializeComponent();
    }
 
    public DetailsForm(int id)
        : this()
    {
        this.id = id;
    }
}

Then you can handle the DoubleClick event in the following way:

void radGridView1_DoubleClick(object sender, EventArgs e)
{
    int id = Convert.ToInt32(this.radGridView1.CurrentRow.Cells["ID"].Value);
    DetailsForm form = new DetailsForm(id);
    form.ShowDialog();
}

I hope this helps.

Greetings,
Svett
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
0
Stefan
Telerik team
answered on 22 Oct 2012, 03:06 PM
Hello David,

Thank you for writing.

In winforms, you should pass the desired values as parameter of the form constructor or set it to form's property. I recommend creating the DetailsForm in the following manner: 
public partial class DetailsForm : Form
{
    private int id;
 
    public DetailsForm()
    {
        InitializeComponent();
    }
 
    public DetailsForm(int id)
        : this()
    {
        this.id = id;
    }
}

Then you can handle the DoubleClick event in the following way:

void radGridView1_DoubleClick(object sender, EventArgs e)
{
    int id = Convert.ToInt32(this.radGridView1.CurrentRow.Cells["ID"].Value);
    DetailsForm form = new DetailsForm(id);
    form.ShowDialog();
}

I hope this helps.

Greetings,
Stefan
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
Tags
GridView
Asked by
dbernett
Top achievements
Rank 2
Answers by
Svett
Telerik team
Stefan
Telerik team
Share this question
or