Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 3rd, 2007, 06:51 PM
Authorized User
 
Join Date: Dec 2006
Location: , , .
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default datagridview cell validation

I posted this to the beginning VB 2005 forum earlier today.
I'm posting it here in hopes that someone will be able to help me.

I need help!
I have been using Google, MSDN, and just about every developer forum I can find on the internet.
I am deliberately entering invalid data into my datagrid cell, but it still 'passes' 'validation'.

Can anyone explain what I am doing wrong?
Here's my code:

Code:
Public Class frmScanEquipmentIn
    Private intPhoneIdentity As Integer
    Private intNetworkID As Integer
    Private strCellESN As String
    Dim strConn As SqlConnection
    Private APC_WirelessConnectionString As String = DBHandling.DetermineServer(strConn)

...
    Private Sub dgvEquipment_CellValidated(ByVal sender As Object, _
        ByVal e As DataGridViewCellEventArgs) _
        Handles dgvEquipment.CellValidated
        dgvEquipment.Rows(e.RowIndex).ErrorText = Nothing
    End Sub
    Private Sub dgvEquipment_CellLeave(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
        Handles dgvEquipment.CellLeave

    End Sub
    Private Sub EquipmentValidationByCell(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.DataGridViewCellParsingEventArgs) _
        Handles dgvEquipment.CellParsing

        strCellESN = dgvEquipment.Rows(e.RowIndex).Cells(e.ColumnIndex).Value

        If dgvEquipment.Columns(e.ColumnIndex).Name = "ESNDataGridViewTextBoxColumn" Then
            If EquipmentNumberValidation(strCellESN) Then
                dgvEquipment.Rows(e.RowIndex).ErrorText = _
                    "Invalid ESN - please correct"
                e.ParsingApplied = False
            End If
        End If

    End Sub

...

    Private Function EquipmentNumberValidation(ByRef strCellESN As String) As Boolean

        Dim intStrLen As Integer = Len(strCellESN)
        MsgBox("Value, Length of strCellESN: " & strCellESN & ", " & (CType(intStrLen, String)))
        MsgBox("Value of intNetworkID: " & (CType(intNetworkID, String)))

        Select Case intNetworkID
            Case 1
                Select Case Len(strCellESN)
                    Case 11

                    Case 18
                        Return True
                    Case Else
                        Return False
                End Select
            Case 4
                Select Case Len(strCellESN)
                    Case 15
                        Return True
                    Case Else
                        Return False
                End Select
            Case Else
                Return False
        End Select
    End Function
I would really appreciate the help. I have been working on this for 'days' and am getting more and more frustrated. (The upside is that I am learning a LOT about functions, events, properties, etc.)

I have figured out a couple more things since I posted this earlier today, I am now calling the validation routine. But, it calls it for the cell after - this makes no sense to me.
Can someone please explain this to me?

Thanks in advance.
Karen

  #2 (permalink)  
Old July 12th, 2007, 07:21 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: India.
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

u can use CellLeave event to validate DGV's Cell data

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a cell in a DataGridView Martin Woodhouse C# 2008 aka C# 3.0 12 October 3rd, 2008 08:42 AM
Merge Cell in Datagridview of visual basic 2005 Nambot VB.NET 2002/2003 Basics 1 November 12th, 2007 09:02 AM
In-Cell Drop Down Via Data Validation Coby Excel VBA 1 October 16th, 2007 04:13 PM
Enforcing uppercase in a cell in a DataGridView cole C# 2005 2 April 24th, 2007 02:33 PM
DataGridView: Cell BackColor kesar VB How-To 0 January 8th, 2007 08:19 AM



All times are GMT -4. The time now is 05:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.