Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/02/2008, 02:35
JoNhNaTaN
 
Fecha de Ingreso: febrero-2008
Mensajes: 54
Antigüedad: 16 años, 2 meses
Puntos: 0
Problema: celdas vacias DataGridView

Hola manes como veran en la imagen, lo que quiero es q el programa me tenga en cuenta solo a aquellas celdas q esten llenas y q omita a las vacias, ya q el elemento de la fila i,j del DG_GRILLA se va a sumar con el elemento de la fila 1,j (es decir el indice de la fila i de la columna j correspondiente del DG_GRILLA tiene q ser tener el mismo indice q la columna j de la fila 1 del DG_Gri) y se elije al menor de ellos para ser el nuevo elemento del DG_Gri.





Código:
url de la imagen por si no se vea:
http://www.cuelgalo.com/viewer.php?id=1204273258_problema.JPG
disculpen por el link

bueno creo q en la imagen esta mas explicado y dejo el codigo pa q me puedan ayudar mejor, gracias de antemano...

Atte Jh.

Cita:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim n, var, cont As Integer
Dim i, j, g, limite As Integer
n = Me.DG_GRILLA.ColumnCount
Me.Label2.Text = n.ToString()
Me.DG_Gri.Rows(0).Cells(0).Value = 0
Me.DG_Gri.Rows(1).Cells(0).Value = "--"

Me.DG_Gri.Rows(0).Cells(1).Value = Me.DG_GRILLA.Rows(0).Cells(1).Value + Me.DG_Gri.Rows(0).Cells(0).Value
Me.DG_Gri.Rows(1).Cells(1).Value = 1

For j = 2 To n - 1
limite = j - 1
g = 0
var = 0

i = 0

Dim sum(limite) As Integer
For i = 0 To limite

If CStr(Me.DG_GRILLA.Rows(i).Cells(j).Value) <> "" Then
sum(i) = Me.DG_GRILLA.Rows(i).Cells(j).Value + Me.DG_Gri.Rows(0).Cells(i).Value


End If

cont = i

Next

For g = 0 To limite
If g = limite Then

Me.DG_Gri.Rows(0).Cells(j).Value = sum(g).ToString()

End If
If (g <> limite) Then

If sum(g) < sum(g + 1) Then

var = sum(g)
sum(g) = sum(g + 1)
sum(g + 1) = var

End If
End If
Next
Next
End Sub
Private Sub sellar()
Dim n, i, j As Integer
n = Me.DG_GRILLA.Rows.Count
For i = 0 To n - 1
For j = 0 To n - 1

If CStr(Me.DG_GRILLA.Rows(i).Cells(j).Value) <> "" Then
Me.DG_GRILLA.Rows(i).Cells(j).Style.BackColor = Color.Beige

End If

Next
Next
Me.DG_GRILLA.ReadOnly = True
End Sub