I have a DataGrid on my form that users type in numbers. The problem them I am having is that if they do not hit enter after they type in the number, that value is never set. How can I change this so its value is set without the user having to push enter?
Is it the way I am pulling the data or something else?
TixTypeQuanity = dataGridTicketTypes.Rows[dataGridTicketTypes.Rows[dgvr.Index].Index].Cells[4].Value.ToString();

1 answers
AFAIK, the value of a cell is set when the cell loses focus, in the CellEndEdit event. This is done either by hitting Enter, Tab, an arrow key or clicking somewhere else.
I'm not sure if this behavior can be changed, but you might be able to get around it by programmatically changing the selected cell.
answered 2 years ago by:
2499
I guess I am still lost as what I need to do. Users type in the numbers, and then click a button on the form to process the order. So in the button I am doing
TixTypeQuanity = dataGridTicketTypes.Rows[dataGridTicketTypes.Rows[dgvr.Index].Index].Cells[4].Value.ToString();
but you are saying I need to set the value? How can I set the value if I am not sure what the value of the textbox inside the datagrid is (since I cant read it with the above code)
answered 2 years ago by:
0
Try to add something "near" as follows...
dataGridTicketTypes.CellEndEdit += new DataGridViewCellEventHandler(dataGridTicketTypes_CellEndEdit);
void dataGridTicketTypes_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
dataGridTicketTypes.CommitEdit();
}
I don't know if thats 100% right (just typed it in here). But it might give you a starting point.
Hope it helps. Good luck!
answered 2 years ago by:
30
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!