none
Letzte Zeile in MSFlxeGrid Markieren RRS feed

  • Frage

  • Hallo  zusammen !

    Habe eine Frage, wie kann ich in MSFlexGrid (VB6) letzte zeile (Row) markieren ?

    Montag, 18. Oktober 2010 15:19

Antworten

  • Hallo API Checker,

    Schau Dir mal den folgenden Codeschnipsel an. Vielleicht kann er Dir weiter helfen.

    Private Sub Form_Load()
      MSFlexGrid1.SelectionMode = flexSelectionByRow
    End Sub
    
    Private Sub cmdPopulate_Click()
    
    Dim conn As New ADODB.Connection '//Verweis auf Microsoft ActiveX Data Objects 2.8 Library
    Dim rs As New ADODB.Recordset
    Dim sConnString As String
    
    sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\Northwind.mdb"
    conn.Open sConnString
    rs.Open "SELECT Employees.FirstName FROM Employees", conn, adOpenKeyset, adLockOptimistic
    
    PopulateFlexGrid MSFlexGrid1, rs '//MSFlexGrid wird mit Daten gefüllt
    
    rs.Close
    conn.Close
    
    End Sub
    
    Public Function PopulateFlexGrid(FlexGrid As Object, rs As Object) As Boolean
    
    On Error GoTo ErrorHandler
    
    If Not TypeOf FlexGrid Is MSFlexGrid Then Exit Function
    
    If Not TypeOf rs Is ADODB.Recordset Then Exit Function
    
    Dim i As Integer
    Dim j As Integer
    
    FlexGrid.FixedRows = 1
    FlexGrid.FixedCols = 0
    
    
    If Not rs.EOF Then
      FlexGrid.Rows = rs.RecordCount + 1
      FlexGrid.Cols = rs.Fields.Count
    
    
      For i = 0 To rs.Fields.Count - 1
        FlexGrid.TextMatrix(0, i) = rs.Fields(i).Name
      Next i
      
      i = 1
    
      Do While Not rs.EOF
    
      For j = 0 To rs.Fields.Count - 1
    
      If Not IsNull(rs.Fields(j).Value) Then
        FlexGrid.TextMatrix(i, j) = _
        rs.Fields(j).Value
      End If
      
      Next j
      
      i = i + 1
      
      rs.MoveNext
      Loop
      
    End If
    
    PopulateFlexGrid = True
    ErrorHandler:
    Exit Function
    End Function
    
    Private Sub Command1_Click()
    
    With MSFlexGrid1
      .Row = MSFlexGrid1.Rows - 1
      .TopRow = MSFlexGrid1.Row
      .RowSel = MSFlexGrid1.Row
      .Col = 0
      .ColSel = .Cols - 1
    End With
    
    End Sub
    

    Grüße,

    Robert

    Montag, 15. November 2010 08:55
    Moderator