Cell edit of datagridview
Posted on 2006-10-23
Below is a routine I'm designing associated with editing a datagridview. Currently my select case = 1 does not require the user to click directly in the box to modify the checkbox. I'm trying to design code for case 7 and 8 which are columns 7 and 8.
Private Sub grdviewInvoices_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdviewInvoices.MouseUp
Dim hitTest As DataGridView.HitTestInfo = grdviewInvoices.HitTest(e.X, e.Y)
If hitTest.Type = DataGridViewHitTestType.Cell Then
Dim drvInvoice As DataRowView
drvInvoice = dvInvoice(hitTest.RowIndex.ToString)
Select Case hitTest.ColumnIndex.ToString
Case Is = 1 ' checkbox
If dvInvoice(hitTest.RowIndex.ToString)("apply").ToString = True Then
drvInvoice("apply") = False
drvInvoice("apply") = True
Case Is = 7 ' payment_amount
Case Is = 8 ' credit_to_be_applied
My columns 7 and 8 are editable $$ fields that I would like to have work in the following manner when the user clicks on them.
By default it works this way:
1) 1st time you click a cell.....it highlights the COMPLETE cell.
2) 2nd time you click a cell....it highlights the cell value (which includes the $ since DefaultCellStyle.Format = "C") .
I would like for it to work this way:
1) The $ is stripped from the value.
2) 1st click....highlights the cell value.
I don't know if it's possible but any efforts to help would be greatly appreciated!