none
El label si llega al 100% el Value de row.Cells(3).Value no llega al 100% RRS feed

  • Pregunta

  • Hola tengo este problema el value de esta celda tendria que llegar al 100% y se me queda en 98% o 99%

    gracias

    De aqui coge los datos para row.Cells(3).Value

    Protected Overrides Function GetFormattedValue( _
                ByVal value As Object, _
                ByVal rowIndex As Integer, _
                ByRef cellStyle As DataGridViewCellStyle, _
                ByVal valueTypeConverter As TypeConverter, _
                ByVal formattedValueTypeConverter As TypeConverter, _
                ByVal context As DataGridViewDataErrorContexts _
                ) As Object
                Static emptyImage As Bitmap = New Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                GetFormattedValue = emptyImage
            End Function
    
            Protected Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal clipBounds As System.Drawing.Rectangle, ByVal cellBounds As System.Drawing.Rectangle, ByVal rowIndex As Integer, ByVal cellState As System.Windows.Forms.DataGridViewElementStates, ByVal value As Object, ByVal formattedValue As Object, ByVal errorText As String, ByVal cellStyle As System.Windows.Forms.DataGridViewCellStyle, ByVal advancedBorderStyle As System.Windows.Forms.DataGridViewAdvancedBorderStyle, ByVal paintParts As System.Windows.Forms.DataGridViewPaintParts)
                Dim progressVal As Integer = CType(value, Integer)
                Dim percentage As Single = CType((progressVal / 100), Single)
                Dim backBrush As Brush = New SolidBrush(cellStyle.BackColor)
                Dim foreBrush As Brush = New SolidBrush(cellStyle.ForeColor)
                ' Call the base class method to paint the default cell appearance.
                MyBase.Paint(g, clipBounds, cellBounds, rowIndex, cellState, _
                    value, formattedValue, errorText, cellStyle, _
                    advancedBorderStyle, paintParts)
                If percentage > 0.0 Then
                    ' Draw the progress bar and the text
                    g.FillRectangle(New SolidBrush(Color.Chartreuse), cellBounds.X + 1, cellBounds.Y + 2, Convert.ToInt32((percentage * cellBounds.Width - 1)), cellBounds.Height - 4)
                    g.DrawString(progressVal.ToString() & "%", cellStyle.Font, foreBrush, cellBounds.X + 40, cellBounds.Y + 4)
                    
                Else
                    'draw the text
                    If Not Me.DataGridView.CurrentCell Is Nothing AndAlso Me.DataGridView.CurrentCell.RowIndex = rowIndex Then
                        g.DrawString(progressVal.ToString() & "%", cellStyle.Font, New SolidBrush(cellStyle.SelectionForeColor), cellBounds.X + 40, cellBounds.Y + 4)
                    Else
                        g.DrawString(progressVal.ToString() & "%", cellStyle.Font, foreBrush, cellBounds.X + 40, cellBounds.Y + 4)
                    End If
                End If
            End Sub
    Aqui abajo esta lo que hace que funcione el 100% en el label 23
    Sub Cuenta_Regresiva_Prueba()
           
    
    
    
            If Label6.Text = 0 And Label7.Text = 0 And Label8.Text = 0 Then
                Timer1.Enabled = False
    
            Else
    
    
                If Label7.Text = 0 And Label8.Text > 0 Then
                    If Label6.Text > 0 Then
                    Else
                        Label8.Text -= 1
                        Label8.Text = If(Label8.Text < 10, "0", "") & Label8.Text.ToString()
    
                        Label7.Text = 60
                    End If
    
                Else
    
                End If
                If Label6.Text = 0 And Label7.Text > 0 Then
                    Label7.Text -= 1
                    Label7.Text = If(Label7.Text < 10, "0", "") & Label7.Text.ToString()
                    Label6.Text = 59
                Else
                    Label6.Text -= 1
                    Label6.Text = If(Label6.Text < 10, "0", "") & Label6.Text.ToString()
                End If
            End If
            Dim cuenta As Integer = (((Label8.Text * 60) + (Label7.Text)) * 60) + Label6.Text
            For Each row As DataGridViewRow In DataGridView1.Rows
                Dim tiempoFila = ((row.Cells(2).Value) * 60)
                If tiempoFila >= cuenta Then
                    Label23.Text = (((tiempoFila - cuenta) * 100) / tiempoFila)
                    row.Cells(3).Value = (((tiempoFila - cuenta) * 100) / tiempoFila)
                   
                End If
                If row.Cells(3).Value = 100 Then
    
                    row.Cells(3).Value = "Completado"
                End If
            Next
            
    
        End Sub 

      



    • Editado JETET domingo, 20 de diciembre de 2015 6:43
    domingo, 20 de diciembre de 2015 6:40