jeffrey4u's Profile User Rating: -----

Reputation: -1 Dishonored
Group:
Members
Active Posts:
26 (0.01 per day)
Joined:
11-February 09
Profile Views:
571
Last Active:
User is offline Feb 20 2014 10:15 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0

Latest Visitors

Icon   jeffrey4u has not set their status

Posts I've Made

  1. In Topic: Check for empty datagridview cells

    Posted 19 Feb 2014

    thank u very much for not given up on me.
    Your effort was very very helpful.

     Private Sub datViewFix_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs) Handles datViewFix.EditingControlShowing
            Dim txtBox As TextBox = CType(e.Control, TextBox)
            RemoveHandler txtBox.KeyPress, AddressOf txtKeyPress
            AddHandler txtBox.KeyPress, AddressOf txtKeyPress
            RemoveHandler txtBox.KeyDown, AddressOf TextBox_KeyDown
            AddHandler txtBox.KeyDown, AddressOf TextBox_KeyDown
        End Sub
    
    
        Private Sub txtKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
        ' Check for delete or backspace AND your appropriate result to EmptyCount and Disable Button and exit the sub because this is enough to react to this event.    
    	If e.KeyChar = ControlChars.Back Then            
                If EmptyCount() = 0 Then 'Check empty count for the appropriate value that would cause enable
                    btnSave.Enabled = True
                Else
                    btnSave.Enabled = False
                End If
            Else
                If EmptyCount() <= 1 Then 'Check empty count for the appropriate value that would cause enable
                    btnSave.Enabled = True
                Else
                    btnSave.Enabled = False
                End If
            End If
        End Sub
    
    
        Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
            ' Check for delete or backspace AND your appropriate result to EmptyCount and Disable Button and exit the sub because this is enough to react to this event.
            If e.KeyCode = Keys.Delete Then
                If EmptyCount() = 0 Then 'Check empty count for the appropriate value that would cause enable
                    btnSave.Enabled = True
                Else
                    btnSave.Enabled = False
                End If
            End If
        End Sub
    
    
        Private Function EmptyCount() As Integer
            Dim Count As Integer = 0
            For Each r As DataGridViewRow In Me.datViewFix.Rows
                If r.Cells(1).Value Is Nothing OrElse r.Cells(1).Value.ToString = "" Then Count += 1
                If r.Cells(2).Value Is Nothing OrElse r.Cells(2).Value.ToString = "" Then Count += 1
            Next
            Return Count
        End Function
    


    It works just fine (though it has some little work around)
    Thank u again as i consider this post RESOLVED
  2. In Topic: Check for empty datagridview cells

    Posted 17 Feb 2014

    Still not getting it done
    i have attach a sample of the project (where am actually facing the problem)
    thank you
  3. In Topic: Check for empty datagridview cells

    Posted 15 Feb 2014

    see image
  4. In Topic: Check for empty datagridview cells

    Posted 15 Feb 2014

    The codes below work just fine but what i have realize is

    that the code doesn't execute immediately after the the last

    cell is filled but wait until i leave the cell.
    Private Sub datViewFix_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles datViewFix.EditingControlShowing
            If Me.datViewFix.CurrentCell.ColumnIndex = 1 Or Me.datViewFix.CurrentCell.ColumnIndex = 2 Then
                Dim txtbox As TextBox = CType(e.Control, TextBox)
                If Not (txtbox Is Nothing) Then
                    RemoveHandler txtbox.KeyPress, AddressOf txtBox_KeyPress
                    AddHandler txtbox.KeyPress, AddressOf txtBox_KeyPress                
                End If
            End If
        End Sub
    
        Private Sub txtBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
            If e.KeyChar = Chr(32) Then 'Space was pressed
                e.Handled = True
            Else
    	Dim bolCount As Boolean = False
    
            For i As Integer = 0 To datViewFix.RowCount - 1
                If datViewFix.Rows(i).Cells.Item(1).Value Is Nothing Or datViewFix.Rows(i).Cells.Item(2).Value Is Nothing Then
                    bolCount = True
                    Exit For
                Else
                    bolCount = False
                End If
            Next
           
            If bolCount = True Then
                btnSave.Enabled = False
            Else
                btnSave.Enabled = True
            End If
    
            End If
        End Sub
    
    
    


    i want the btnSave to be enabled as soon as the last cell if filled
  5. In Topic: Check for empty datagridview cells

    Posted 13 Feb 2014

    Good day and thanks for ur contributions
    Got it fixed using ur suggestion, Charlie

    But have notice another unfriendly behaviour
    The code is not executed there's a key pressed
    but rather wait till the user leaves the cell.
    I tried with timer but couldn't help

    any idea?

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

jeffrey4u hasn't added any friends yet.

Comments

jeffrey4u has no profile comments yet. Why not say hello?