Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cell edit of datagridview

Posted on 2006-10-23
2
Medium Priority
?
718 Views
Last Modified: 2008-02-01
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)
            drvInvoice.BeginEdit()
            Select Case hitTest.ColumnIndex.ToString
                Case Is = 1 ' checkbox
                    If dvInvoice(hitTest.RowIndex.ToString)("apply").ToString = True Then
                        drvInvoice("apply") = False
                    Else
                        drvInvoice("apply") = True
                    End If
                Case Is = 7 ' payment_amount
                Case Is = 8 ' credit_to_be_applied
            End Select
            drvInvoice.EndEdit()
        End If
    End Sub


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!

Sincerely,
Phil Tate
0
Comment
Question by:TSFLLC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
gangwisch earned 1500 total points
ID: 17789867
highlights complete cell
if numclicks=1 then
datagridview1.item(e.columnindex,e.rowindex).selected=true
else
datagridview1.item(e.columnindex,e.rowindex).value=replace(datagridview1.item(e.columnindex,e.rowindex).value,"$","") 'strips off $ sign
datagridview1.item(e.columnindex,e.rowindex).beginedit

end if
0
 

Author Comment

by:TSFLLC
ID: 17790378
with the defaultcellstyle.format = "C" it doesn't appear to be able to strip the $, but that's not a great issue.

Also, with datagridview1.beginedit(True) selects the entire cell value of the current field.

This at least got me in the right direction.

Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question