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

Set new row in edit mode programartically

4 Answers 209 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kim Bouchard
Top achievements
Rank 1
Kim Bouchard asked on 11 Nov 2010, 01:02 PM
Hi,

i've got some problems when i want to put a newly added row in edit mode through code.
My scenario is:
Q 2010 Sp2 GridView, which is bound to a BindindSource. The BindingSource is bound to an ObjectResult (EF4).
I wanted to add a new row via BindingSource.AddNew method.
Then i wanted the first cell of that newly added row to be in edit mode without any extra clicks.
The cell editor should be shown and ready to receive my input.

None of forums threads regarding "putting a cell in edit mode programatically" worked for me.
So i am looking for a general solution.

Kind Regards
Kim

4 Answers, 1 is accepted

Sort by
0
Kim Bouchard
Top achievements
Rank 1
answered on 11 Nov 2010, 01:30 PM
Funny thing.
My last try now finally worked.

After calling BindingSource.AddNew i do Application.DoEvents() and
now everything works as expected.

I don't why, but i guess it is because of the sync process between CurrentRow and SelectedRow
and there are maybe some pending events, which gets processed by calling Application.DoEvents.

Maybe someone can confirm my thoughts ....

Kind Regards
Kim
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 11 Nov 2010, 01:31 PM
Hi

Even though this is not using BindingSource, the effect should be the same.
Have a look at this forum post

hope that helps
Richard
0
Kim Bouchard
Top achievements
Rank 1
answered on 11 Nov 2010, 03:06 PM
Hi Richard,

thanks for your reply.
radGridview.BeginUpdate() and radGridView.EndUpdate() seems to solve the "problem".
I placed my BindingSource.AddNew between them.

The newly added row then can be setted into edit mode via radGridView.CurrentRow.Cells[0].BeginEdit().

Kind Regards
Kim
0
Richard Slade
Top achievements
Rank 2
answered on 11 Nov 2010, 03:12 PM
Glad that helped Kim.
Please remember to mark as answer so others can find the solution too.

All the best
Richard
Tags
GridView
Asked by
Kim Bouchard
Top achievements
Rank 1
Answers by
Kim Bouchard
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Share this question
or