Home > other >  How to make the datagridview CurrentCellDirtyStateChanged events to submit the data, the cell will n
How to make the datagridview CurrentCellDirtyStateChanged events to submit the data, the cell will n

Time:02-07

As title, because some requirements, DataGridView a content in the input, will call to the content submitted, but after doing so, controls would be you input the content is done, so the content selection, this makes the cannot continue input, how to avoid all the selected?


Chen Jinwei

CodePudding user response:

Hi Chen Jinwei,
I still have not been able to reproduce your problem, but as you say, you can try to use the code to locate the position of the cursor, you can refer to the following:
DataGridView1. CurrentCell=dataGridView1. Rows [0]. Cells [0];
DataGridView1. BeginEdit (false);
TextBox TB=(TextBox) dataGridView1. EditingControl;
TB. SelectionStart=0;
Regards,
Kyle

CodePudding user response:

Hi Chen Jinwei,
I subscribed to CurrentCellDirtyStateChanged events, and execute the following code in the event instead of "content submitted"
Private void dataGridView1_CurrentCellDirtyStateChanged (object sender, EventArgs e)
{
Console. WriteLine (dataGridView1. CurrentCell. Value);
}
The results are as follows:

Not what you say content selection, can you provide a specific code can reproduce your problem?
Regards,
Kyle

CodePudding user response:

I am in CurrentCellDirtyStateChanged submit data at any time, that will be submitted after the cell selection, for future generations, not directly input again, can only use the mouse to reposition the input point to the end, I want to ask, how to change the presentation all perfection,
Private void dataGridView1_CurrentCellDirtyStateChanged (object sender, EventArgs e)
{
If (this. IsCurrentCellDirty)
{
This.Com mitEdit MIT (DataGridViewDataErrorContexts.Com);
}

Is only after the execution of the submitted, with code reset input point to the end?

Chen Jinwei

CodePudding user response:

Hi Chen Jinwei,
I still have not been able to reproduce your problem, but as you say, you can try to use the code to locate the position of the cursor, you can refer to the following:
DataGridView1. CurrentCell=dataGridView1. Rows [0]. Cells [0];
DataGridView1. BeginEdit (false);
TextBox TB=(TextBox) dataGridView1. EditingControl;
TB. SelectionStart=0;
Regards,
Kyle

CodePudding user response:

Ok, thank you! Chen Jinwei

CodePudding user response:

I just want to ask how datagridview binding private void dataGridView1_CurrentCellDirtyStateChanged (object sender, EventArgs e) the incident,
  • Related