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

Add and select new row on Grid Enter Event

3 Answers 167 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Khalid
Top achievements
Rank 1
Khalid asked on 29 Jun 2012, 08:52 AM
I have a problem focusing the Telerik RadGridView by keyboard,

I need to accomplish the following :-

if the grid is empty it should add a new row and select the first visible row and column in edit mode
else
it should not add a new row but select the first visible row and column in edit mode.

I tried many currentrow, currentcell , isselected and beginedit() but to no avail :(


3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 04 Jul 2012, 07:00 AM
Hello Khalid,

Thank you for writing.

Please refer to the following code snippet, which demonstrates how to achieve the desired functionality:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        radGridView1.Columns.Add("col 1");
        radGridView1.Columns.Add("col 2");
        radGridView1.Columns.Add("col 3");
        radGridView1.Enter += new EventHandler(radGridView1_Enter);
    }
 
    void radGridView1_Enter(object sender, EventArgs e)
    {
        if (radGridView1.Rows.Count == 0)
        {
            radGridView1.Rows.Add("test", "test", "test");
        }
        else
        {
            Console.WriteLine(radGridView1.ChildRows.Count);
            radGridView1.ChildRows[0].IsCurrent = true;
            radGridView1.Columns[0].IsCurrent = true;
        }
        radGridView1.BeginEdit();
    }
}

I hope that the provided information addresses your question. Let us know if you have any other questions.
 
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Khalid
Top achievements
Rank 1
answered on 06 Jul 2012, 10:28 AM
my grid is data bound.

the code you provided did not work,

but here is the solution

radgridview1.crrentrow.cells(0).isslected = true
radgridview1.crrentrow.cells(0).beginedit()



0
Stefan
Telerik team
answered on 09 Jul 2012, 01:17 PM
Please excuse me for not providing you with a sample with bound grid. I just did not know that you are using such a grid, thus I created a small sample.

I am glad to hear that you have found a suitable solution for your case. Let us know if you have any other questions.

Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Khalid
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Khalid
Top achievements
Rank 1
Share this question
or