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

BeginEdit for added row fails on first insert

1 Answer 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alistair Wardlaw
Top achievements
Rank 1
Alistair Wardlaw asked on 17 Nov 2009, 12:31 AM
What I am trying to do is add a new row to a grid and then automatically set it to edit mode. What i'm finding is this fails on the first row that is inserted, but for every other row it works fine. I have tried setting current row/column a few different ways and found the same behaviour. Have set up a basic example of it below.

        private void Form1_Load(object sender, EventArgs e) 
        { 
            radGridView1.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; 
            radGridView1.ShowGroupPanel = false
            radGridView1.MasterGridViewTemplate.EnableGrouping = false
            radGridView1.MasterGridViewTemplate.AllowAddNewRow = false
 
            GridViewComboBoxColumn col1 = new GridViewComboBoxColumn("Test1""Test1"); 
            col1.DropDownStyle = RadDropDownStyle.DropDownList; 
            col1.FieldName = "Test1"
            col1.DisplayMember = "Test1"
            col1.DataType = typeof (int); 
            col1.DataSource = new[] {1, 2, 3}; 
            col1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; 
 
            radGridView1.Columns.Add(col1); 
        } 
 
        private void button1_Click(object sender, EventArgs e) 
        { 
            int rowCount = radGridView1.Rows.Count; 
 
            object[] values = {1}; 
            radGridView1.Rows.Add(values); 
            radGridView1.MasterGridViewInfo.CurrentRow = radGridView1.Rows[rowCount]; 
 
            radGridView1.Rows[rowCount].Cells["Test1"].BeginEdit(); 
        } 

What happens is the first row will get inserted without being in edit mode. if you click the button every other row works correctly.

Is there anything that i'm doing wrong in this case?

Version i'm using is: Q2 2009 SP1.

Have attached an image of the result. http://bayimg.com/image/maefbaaco.jpg

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 18 Nov 2009, 01:59 PM
Hi Alistair,
 
You should call Application.DoEvents method before calling the BeginEdit method. This will ensure that all visual elements are created in RadGridView. If you need further assistance with this, just write us back.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Alistair Wardlaw
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or