winforms - C# DataGridView Adding a Row - When validating, how do I know the row is new and not yet committed? -
I have a client who has a problem with the DataGrid view in a Windows app. They are calling cell-based events, but They want to verify separately for the cell if it is in line that is already committed back to the data source, if it is a row that is being added before (and not yet committed (user yet line I have not left it). I'm close to IsNewRow Ttti tried, but as soon as you start typing in the line, another "new line" is added, so the row you are working with is no longer considered a new line. The row has not been committed yet because you can press Esc to cancel the edit, and the whole line goes away.
Is there any way to tell that the currently edited row actually " New punt It means that it has not been changed back to the data source?
In a way I Some have achieved something similar in the past, using the ID property of my items which are linked to the list. For example, if I have binding list
where user is something like this:
public class name {public string name {get; Set; } Receive public ID { Set; }}
Then I can tie my list like this:
dataGridView1.AutoGenerateColumns = false; _users = new binding list & lt; Users & gt; (); _users. Add (new name () {name = "joe", id = 1}); _users. Add (new name () {name = "pete", id = 2}); BindingSource1.DataSource = _names; Data Gridviewtextbox column call1 = new datagridviewtxtbox column (); Col1.DataPropertyName = "name"; DataGridView1.Columns.Add (col1); DataGridView1.DataSource = _users;
Then, when DatagreeDWV provides a new line, it will have an ID of 0 (default value for integer).
Each object that has a non-zero id in the database.
There can also be a way to get it using a binding resource, but I find a quick look at the properties and I do not miss anything.
Comments
Post a Comment