why BeforeRowLeave is not fired when leave the grid? - c#

I have a devexpress grid: each row has a checkbox and a text column, when I check the checkbox, the text column is updated. After the text column is updated, I would like to manual save the row to database, but I need to do some convert before I save it. So in beforeRowleave event, I write such convert data and save logic.
My grid is on a form, there is another button on the form "Save Button". Now in my grid I have 3 rows of record, Let's call them R1, R2 and R3.
I check the checkbox in R1, R2 and R3 one by one and then I click "Save Button". But it seems only R1 and R2 fires the beforeRowLeave event, R3 didn't fire this event. Does this because the gridview loses the focus?
How could I fire a similar event for R3? Thanks a lot!

The BeforeLeaveRow event is not called because the focused GridView row is not actually changed - it is the same last row in the grid. As a solution, I would suggest that you move your logic to the RowUpdated event instead.

Related

Prevent user from leaving DataGridViewRow in WinForms parent/child form

I have a form with a read-only datagridview on the left and various controls on the right.
Instead of allowing users to edit the datagridview row directly, I load the values for the selected record into the controls on the right, where they can do the editing.
However, after changing values on the right, I select a new row in the grid, the RowValidating event is not getting fired, or is not getting fired before the RowEnter event.
In this scenario, how can I prevent the user from moving to a different row on the grid if the validation of the child controls for the current row fails?
Thanks in advance for the help.

Handle select click event datagridview

My WinForm project in c#, I have DataGridview that i want to disable cell selection with mouse clicking in editing.
To be more specific; when the user keypress"=" en event fired and disable to select cell by clicking.I want to do something different instead of cell selection. Only by keypressing"ESC" or "Enter" allow to leave cell editing.
I added picture for understanding.Please help.

How to trigger a button event while checked status change for checkbox

I want to generate button click event while checking checkbox in data grid view. How it this possible?
I put my perform click event in dataGridView1_CellContentClick.
When I click on any row first time button event could not perform, however when I click other row then it will perform a button click event for first row click. How to solve this issue?
If you want to know when anywhere in the cell is clicked, then its best to use CellClick or probably CellMouseDown.
If you are not after whitespace in the row or column then its best to use CellContentClick (for columns like checkbox, button, link etc)..

Button that actions on rows in a datagridview c#

Can I have a button in a form, outside a DataGridView and on click of this button to perform an action on the rows of the DataGridView?
Yes on this button click event you can call datagridview event. Use DataGridView.CurrentRow property to get the selected row

Asp.net Keydown Event not always fired within GridView

Within a griview (using IE), cells in one column are clickable (through gridview row command event) and once a cell is clicked it displays a hidden textbox (visible = false before the cell is clicked); users can enter text into the textbox and to allow saving changes made to the textbox users are told to press Tab key.
The saving is done through using Javascript by checking keycode in keydown event, it simply checks when keycode = 9 (Tab key) __doPostback('OnClick','SaveButton'); in codebehind SaveButton onclick event simply calls a store procedure to save the new text changes into database.
The problem I have is keydown event is not ALWAYS fired though it works most of the time. There seems to be no difference to the situation when it works and when it doesn't, so to me it's a bit random and I have to emphaise that it works 90% of the time.
Worth mentioning that when users click the cell to edit the textbox, gridview row updating event is fired first since I need to enable gridview row updating event not only for this column text changes but also for other columns data updating.
When everything 'works' after user pressing the Tab key, the event sequence is:
Gridview row updating
Keydown/SaveButton click
Gridview row updating
I don't understand what triggers the event 3 i.e. the second gridview row updating event though it doesn't do any harm to anything as it's after the text being saved into database. But when pressing Tab key doesn't work (text not saved) the second gridview row updating event is not fired; only the 1st row updating event is fired and textbox changes are lost reverting back to the original text.
I'm new to asp.net and hope someone can shred some light on this problem.
I found out why GridView row updating event fired for the 2nd time, it's because AutoPost for the editable textbox being set to True.
silly me...

Categories

Resources