Posted on 2004-11-15
Hi everyone, I have a problem editing data in a datagrid.
When a user changes values in a column on the datagrid, I want to perform a calulation and put the result in another column. This works fine, except the change only occurs afterthe user leaves the current row. I want the change to occur without the user having to do this.
My code is as follows:
ts1 = New DataGridTableStyle
ts1.MappingName = "gw_BulkChanges"
Dim yourcolumn As New DataColumn
yourcolumn.ColumnName = "newmargin"
yourcolumn.DataType = GetType(Double)
yourcolumn.Expression = "(((dec_newretail*0.8510638)-dec_newcost)/(dec_newretail*0.8510638))*100"
Dim myDataCol_10 As New DataGridTextBoxColumn
myDataCol_10.HeaderText = "New Margin"
myDataCol_10.MappingName = "newmargin"
myDataCol_10.Width = 75
myDataCol_10.NullText = ""
myDataCol_10.ReadOnly = True
myDataCol_10.Alignment = HorizontalAlignment.Right
'myDataCol_10.DataAlignment = HorizontalAlignment.Right
myDataCol_10.Format = "f"
Private Sub grd_BulkDetail_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles grd_BulkDetail.CurrentCellChanged
Dim gridCurrencyManager As CurrencyManager = _
Essentially, what I need is for the sub just above to fire when the text is changed, not when the user leaves the line in the grid.
I have done this before and had it working so I know it's possible.
Any help would be great