DataGridView
-
I have a DataGridView with many DataGridViewTextBoxColumn(s). As soon as the value is changed within the cell I want to send it to my object--not once the cell loses focus--how can I do this? I tried to cast it to a textbox and created an event handler for TextBox's TextChanged event but the problem is I need the column and row info which you normally access through e.ColumnIndex and e.RowIndex of CellEndEdit and other events. Any ideas? One thing I can do is on CellEnter I can grab the column number and row number and save it in a variable and use it later but is there an alternative? I need realtime event like the textbox's TextChanged event.
CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
-
I have a DataGridView with many DataGridViewTextBoxColumn(s). As soon as the value is changed within the cell I want to send it to my object--not once the cell loses focus--how can I do this? I tried to cast it to a textbox and created an event handler for TextBox's TextChanged event but the problem is I need the column and row info which you normally access through e.ColumnIndex and e.RowIndex of CellEndEdit and other events. Any ideas? One thing I can do is on CellEnter I can grab the column number and row number and save it in a variable and use it later but is there an alternative? I need realtime event like the textbox's TextChanged event.
CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
So, if I type in 'this is a stupid idea', you want to send 21 change messages ? Do you want to save you data 21 times ? I would imagine the way to do this, is to set the Tag of the Textbox to contain the column and row, so you can parse it from there.
Christian Graus Driven to the arms of OSX by Vista.
-
So, if I type in 'this is a stupid idea', you want to send 21 change messages ? Do you want to save you data 21 times ? I would imagine the way to do this, is to set the Tag of the Textbox to contain the column and row, so you can parse it from there.
Christian Graus Driven to the arms of OSX by Vista.
I actually did it by saving the column number and the row number at CellEnter.
Christian Graus wrote:
So, if I type in 'this is a stupid idea', you want to send 21 change messages ?
Yes.
Christian Graus wrote:
Do you want to save you data 21 times ?
No, just probe the object 21 times. For example, private void textBox_TextChanged(Object sender, EventArgs e) { this.customer.Name = this.textBox.Text; } where customer is the object is I am probing.
CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
-
I actually did it by saving the column number and the row number at CellEnter.
Christian Graus wrote:
So, if I type in 'this is a stupid idea', you want to send 21 change messages ?
Yes.
Christian Graus wrote:
Do you want to save you data 21 times ?
No, just probe the object 21 times. For example, private void textBox_TextChanged(Object sender, EventArgs e) { this.customer.Name = this.textBox.Text; } where customer is the object is I am probing.
CodingYoshi Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
If you don't want to send 21 times message then you should think about how to catch your changes. One possibility is On leave event but you don't want do that. I think you should use on leave cell event.