I have a DataGridView I'm trying to edit manually.
-grid.ReadOnly is false
-all Columns ReadOnly are false
-EditMode is OnKeyStroke
-not bound to anything
-no data validation
If I enter a value in the grid and then press enter or click onto another cell, the entered value disappears.
I have the following events setup on the DataGridView:
CellMouseDoubleClick
private void trackEditor_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
DataGridView grid = sender as DataGridView;
//checks if the cell's value contains a 0. If so, change the value to write to 1. If not, assume the cell value is already 0 and keep the value to write to 0
int val;
if (grid.CurrentCell.Value == null || int.Parse(grid.CurrentCell.Value.ToString()) == 0)
val = 1;
else
val = 0;
grid.CurrentCell.Value = val;
}
CellValueChanged
private void trackEditor_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
string _out = "";
for (int x = 0; x < trackEditor.ColumnCount; x++) {
if (trackEditor.CurrentRow.Cells[x].Value != null)
_out += x + ":" + trackEditor.CurrentRow.Cells[x].Value + ",";
}
richRawTrackData.Text = _out;
}
column.ValueType
andFormattedValueType
are what? Any other odd settings? – CharliefaceValueType
is string. I don't haveFormattedValueType
set – CocoaMix86richRawTrackData.Text
? – Chetan