Results 1 to 4 of 4

Thread: [RESOLVED] Datagridview on cell leave Refresh problem

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Resolved [RESOLVED] Datagridview on cell leave Refresh problem

    I want to send the data that i just entered into a cell to an If-statemens to perform certain functions.

    I an using the following code just for testing purposes:

    1 Code:
    1. Private Sub DGVReceipt_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVReceipt.CellLeave
    2.         Dim row, cell As Integer
    3.         row = e.RowIndex
    4.         cell = e.ColumnIndex
    5.  
    6.         Dim a As String
    7.         a = DGVReceipt.Item(cell, row).Value
    8.     End Sub

    Now I find that the value I entered into the cell doesn't display. Only when i go back to the cell and leave it again will it display.

    How can I get the value to display immediately?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Datagridview on cell leave Refresh problem

    I don't see how that code can do anything useful. You assign the cell value to a local variable that immediately loses scope. You aren't changing anything.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Re: Datagridview on cell leave Refresh problem

    I played with the code some more and got it to do what i wanted.

    vb Code:
    1. Private Sub DGVReceipt_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGVReceipt.CellLeave
    2.         Dim row, cell As Integer
    3.         row = e.RowIndex
    4.         cell = e.ColumnIndex
    5.         DGVReceipt.CommitEdit(DataGridViewDataErrorContexts.Commit)
    6.  
    7.         Dim strNewValue As String
    8.         strNewValue = DGVReceipt.Item(cell, row).Value
    9.         Dim totrows As Integer = DGVReceipt.Rows.Count - 1
    10.  
    11.         Select Case cell
    12.             Case Is = 0 And row < totrows         '\\\\ CATEGORY
    13.  
    14.             Case Is = 1 And row < totrows '\\\\ STOCK
    15.                 If DGVReceipt.Item(cell, row).Value = "-- Add New --" Then
    16.                     frmNewStock.ShowDialog()
    17.                     STOCK_DROPMENU()
    18.                 End If
    19.             Case Is = 2 And row < totrows '\\\\ ESTATE
    20.  
    21.          End Select
    22.  
    23.     End Sub

  4. #4
    New Member
    Join Date
    Aug 2011
    Location
    Bangalore, India
    Posts
    1

    Re: [RESOLVED] Datagridview on cell leave Refresh problem

    Hello guys!

    I am facing similar kind of problem with the Datagridview, I am trying to validate a certain column, and when I check on a value right after I leave the cell, I am not getting the current value, any pointers on this?

    --Vatsa

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width