flexgrid
Hola,
¿cómo hago para escribir en las celdas de un flexgrid en tiempo de ejecución?.
agradeciería la ayuda que me puedan brindar.
¿cómo hago para escribir en las celdas de un flexgrid en tiempo de ejecución?.
agradeciería la ayuda que me puedan brindar.
Hola, te mando un ejemplo a ver si te puede ayudar.
Public Sub CargarGrid()
Dim strObservaciones As String
Dim rs As New ADODB.Recordset
Dim strSql As String
Dim strVinculado As String
On Error GoTo CargarGrid_Err
Me.mfGrid.AllowUserResizing = 3
'Número de columnas fijas
mfGrid.FixedCols = 0
'Número de filas fijas
mfGrid.FixedRows = 0
'Mostramos el Scroll horizaontal y el vertical
mfGrid.ScrollBars = 3
'Numero de Filas
mfGrid.Rows = 1
mfGrid.FocusRect = flexFocusLight
mfGrid.GridLines = flexGridRaised
'Numero de Columnas a mostrar
ReDim FixedColCaptions(nColumnas - 1)
'Cabecera
FixedColCaptions(0) = "IDENTIFICADOR"
FixedColCaptions(1) = "NOMBRE"
FixedColCaptions(2) = "DESCRIPCIÓN"
FixedColCaptions(3) = "SUPERFICIE"
FixedColCaptions(4) = "MEDIDA"
FixedColCaptions(5) = "OBSERVACIONES"
FixedColCaptions(6) = "FLAG"
FixedColCaptions(7) = "TIENE FICHAS"
FixedColCaptions(8) = "ALCANCE"
'Nos situamos en la fila 0
mfGrid.Row = 0
'Numero de Columnas
mfGrid.Cols = nColumnas
Dim j As Long
Dim k As Long
Dim i As Integer
'Rellenamos la cabecera de la filas fijas
For j = 0 To mfGrid.Cols - 1
mfGrid.Col = j
Select Case j
Case 0, 7, 8
mfGrid.ColWidth(j) = 1400
Case 1
mfGrid.ColWidth(j) = 2100
Case 2, 5
mfGrid.ColWidth(j) = 2500
Case 3
mfGrid.ColWidth(j) = 2000
Case 4
mfGrid.ColWidth(j) = 1000
Case 6
mfGrid.ColWidth(j) = 0
End Select
mfGrid.Text = FixedColCaptions(j)
mfGrid.Highlight = flexHighlightWithFocus
mfGrid.CellBackColor = RGB(100, 255, 0)
Next
If rsRecordSet.RecordCount <> 0 Then
rsRecordSet.MoveFirst
End If
For i = 0 To rsRecordSet.RecordCount - 1
If IsNull(rsRecordSet("Observaciones")) Then
strObservaciones = ""
Else
strObservaciones = DameObservacionSinIntro(rsRecordSet("Observaciones"))
End If
If rsRecordSet("Nombre") = strSueloNoUrbanizable Then
strSql = "SELECT * FROM [Ficha SNU/Ambito Territorial] WHERE [Identificador AT] = '" & rsRecordSet("Identificador AT") & "'"
Else
strSql = "SELECT * FROM [Ficha General/Ambito Territorial] WHERE [Identificador AT] = '" & rsRecordSet("Identificador AT") & "'"
End If
rs.Open strSql, oConexion, adOpenKeyset, adLockOptimistic
If rs.RecordCount <> 0 Then
strVinculado = "Si"
Else
strVinculado = "No"
End If
rs.Close
'Se le da formato al campo superficie para que solo saque dos decimales en el grid
mfGrid.AddItem rsRecordSet("Identificador AT") & vbTab & rsRecordSet("Nombre") & vbTab & rsRecordSet("Descripcion") & vbTab & _
Format(rsRecordSet("Superficie"), "###0.00") & vbTab & rsRecordSet("Tipo Medida Superficie") & vbTab & strObservaciones & vbTab & _
strFlagExistente & vbTab & strVinculado & vbTab & _
rsRecordSet("Alcance")
rsRecordSet.MoveNext
Next i
'********************
'Error
'********************
Exit Sub
CargarGrid_Err:
MsgBox "ERROR_CargarGrid_Err " & Err & ". " & Err.Description & " en la línea: " & Erl & ".", vbExclamation + vbOKOnly, "Error."
End Sub
Un saludo
sdemingo
Public Sub CargarGrid()
Dim strObservaciones As String
Dim rs As New ADODB.Recordset
Dim strSql As String
Dim strVinculado As String
On Error GoTo CargarGrid_Err
Me.mfGrid.AllowUserResizing = 3
'Número de columnas fijas
mfGrid.FixedCols = 0
'Número de filas fijas
mfGrid.FixedRows = 0
'Mostramos el Scroll horizaontal y el vertical
mfGrid.ScrollBars = 3
'Numero de Filas
mfGrid.Rows = 1
mfGrid.FocusRect = flexFocusLight
mfGrid.GridLines = flexGridRaised
'Numero de Columnas a mostrar
ReDim FixedColCaptions(nColumnas - 1)
'Cabecera
FixedColCaptions(0) = "IDENTIFICADOR"
FixedColCaptions(1) = "NOMBRE"
FixedColCaptions(2) = "DESCRIPCIÓN"
FixedColCaptions(3) = "SUPERFICIE"
FixedColCaptions(4) = "MEDIDA"
FixedColCaptions(5) = "OBSERVACIONES"
FixedColCaptions(6) = "FLAG"
FixedColCaptions(7) = "TIENE FICHAS"
FixedColCaptions(8) = "ALCANCE"
'Nos situamos en la fila 0
mfGrid.Row = 0
'Numero de Columnas
mfGrid.Cols = nColumnas
Dim j As Long
Dim k As Long
Dim i As Integer
'Rellenamos la cabecera de la filas fijas
For j = 0 To mfGrid.Cols - 1
mfGrid.Col = j
Select Case j
Case 0, 7, 8
mfGrid.ColWidth(j) = 1400
Case 1
mfGrid.ColWidth(j) = 2100
Case 2, 5
mfGrid.ColWidth(j) = 2500
Case 3
mfGrid.ColWidth(j) = 2000
Case 4
mfGrid.ColWidth(j) = 1000
Case 6
mfGrid.ColWidth(j) = 0
End Select
mfGrid.Text = FixedColCaptions(j)
mfGrid.Highlight = flexHighlightWithFocus
mfGrid.CellBackColor = RGB(100, 255, 0)
Next
If rsRecordSet.RecordCount <> 0 Then
rsRecordSet.MoveFirst
End If
For i = 0 To rsRecordSet.RecordCount - 1
If IsNull(rsRecordSet("Observaciones")) Then
strObservaciones = ""
Else
strObservaciones = DameObservacionSinIntro(rsRecordSet("Observaciones"))
End If
If rsRecordSet("Nombre") = strSueloNoUrbanizable Then
strSql = "SELECT * FROM [Ficha SNU/Ambito Territorial] WHERE [Identificador AT] = '" & rsRecordSet("Identificador AT") & "'"
Else
strSql = "SELECT * FROM [Ficha General/Ambito Territorial] WHERE [Identificador AT] = '" & rsRecordSet("Identificador AT") & "'"
End If
rs.Open strSql, oConexion, adOpenKeyset, adLockOptimistic
If rs.RecordCount <> 0 Then
strVinculado = "Si"
Else
strVinculado = "No"
End If
rs.Close
'Se le da formato al campo superficie para que solo saque dos decimales en el grid
mfGrid.AddItem rsRecordSet("Identificador AT") & vbTab & rsRecordSet("Nombre") & vbTab & rsRecordSet("Descripcion") & vbTab & _
Format(rsRecordSet("Superficie"), "###0.00") & vbTab & rsRecordSet("Tipo Medida Superficie") & vbTab & strObservaciones & vbTab & _
strFlagExistente & vbTab & strVinculado & vbTab & _
rsRecordSet("Alcance")
rsRecordSet.MoveNext
Next i
'********************
'Error
'********************
Exit Sub
CargarGrid_Err:
MsgBox "ERROR_CargarGrid_Err " & Err & ". " & Err.Description & " en la línea: " & Erl & ".", vbExclamation + vbOKOnly, "Error."
End Sub
Un saludo
sdemingo
