vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2026
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: scrollen im MSHFlexgrid per Code 
Autor: RalfH
Datum: 26.07.06 08:31

Servus,

mit MSHFlexGrid1.RowSel markiert man nur Zeilen. Zum Scrollen musst Du "MSHFlexGrid1.TopRow" nutzen.

Setz auf eine Form 4 Commandbutton (cmdTopDown, cmdBottomUp, cmdSelBottomUp, cmdSelTopDown) und 1 MSHFlexGrid (MSHFlexGrid1) und füge folgenden Code in das Form-Modul:
Option Explicit
 
Private Sub CheckControlStates()
 
  With MSHFlexGrid1
    cmdTopDown.Enabled = .TopRow < .Rows - RowsVisible
    cmdBottomUp.Enabled = .TopRow > .FixedRows
 
    cmdSelBottomUp.Enabled = .RowSel > .FixedRows
    cmdSelTopDown.Enabled = .RowSel < (.Rows - 1)
  End With
End Sub
 
Private Sub cmdBottomUp_Click()
  With MSHFlexGrid1
    If .TopRow > .FixedRows Then .TopRow = .TopRow - 1
  End With
End Sub
 
Private Sub cmdSelBottomUp_Click()
  With MSHFlexGrid1
    If .RowSel > .FixedRows Then
      .RowSel = .RowSel - 1
    End If
 
    If .RowSel < .TopRow Then
      If .TopRow > .FixedRows Then .TopRow = .TopRow - 1
    End If
  End With
 
  CheckControlStates
End Sub
 
Private Sub cmdSelTopDown_Click()
  With MSHFlexGrid1
    If .RowSel < .Rows - 1 Then
      .RowSel = .RowSel + 1
 
      If .RowSel > .TopRow + RowsVisible - 1 Then
        If .TopRow < .Rows - RowsVisible Then .TopRow = .TopRow + 1
      End If
    End If
  End With
  CheckControlStates
End Sub
 
Private Sub cmdTopDown_Click()
  With MSHFlexGrid1
    If .TopRow < .Rows - RowsVisible Then .TopRow = .TopRow + 1
  End With
End Sub
 
Private Sub Form_Load()
  Dim I As Long
  With MSHFlexGrid1
    For I = .FixedRows To .Rows - 1
      .TextMatrix(I, 0) = Str(I)
    Next I
  End With
 
  With cmdBottomUp
    .Left = 0
    .Top = 0
    .Width = 120 * Screen.TwipsPerPixelX
    .Height = 20 * Screen.TwipsPerPixelY
    .Caption = "Nach oben scrollen"
  End With
 
  With cmdTopDown
    .Left = cmdBottomUp.Left + cmdBottomUp.Width
    .Top = cmdBottomUp.Top
    .Width = 120 * Screen.TwipsPerPixelX
    .Height = 20 * Screen.TwipsPerPixelY
    .Caption = "Nach unten scrollen"
  End With
 
  With cmdSelBottomUp
    .Left = cmdTopDown.Left + cmdTopDown.Width
    .Top = cmdBottomUp.Top
    .Width = 120 * Screen.TwipsPerPixelX
    .Height = 20 * Screen.TwipsPerPixelY
    .Caption = "Nach oben markieren"
  End With
 
  With cmdSelTopDown
    .Left = cmdSelBottomUp.Left + cmdSelBottomUp.Width
    .Top = cmdBottomUp.Top
    .Width = 120 * Screen.TwipsPerPixelX
    .Height = 20 * Screen.TwipsPerPixelY
    .Caption = "Nach unten markieren"
  End With
 
  CheckControlStates
End Sub
 
Private Sub Form_Resize()
  With MSHFlexGrid1
    .Width = ScaleWidth - .Left
    .Height = ScaleHeight - .Top
  End With
 
  CheckControlStates
End Sub
 
Private Sub MSHFlexGrid1_Scroll()
  CheckControlStates
End Sub
 
Private Sub MSHFlexGrid1_SelChange()
  CheckControlStates
End Sub
 
Private Function RowsVisible(Optional ByVal WithFixedRows As Boolean = False) _
  As Long
 
  Dim I As Long, lCnt As Long, sngHeight As Single, sngBorderCorr As Long
 
  With MSHFlexGrid1
 
    If .BorderStyle <> flexBorderNone Then
      If .Appearance = flex3D Then
        sngBorderCorr = 2 * Screen.TwipsPerPixelY
      Else
        sngBorderCorr = 0
      End If
    End If
 
    lCnt = 0
    sngHeight = sngBorderCorr
 
    ' Höhe des Festen Zeilenmbereiches ermitteln
    For I = 0 To .FixedRows - 1
      sngHeight = sngHeight + .RowHeight(I)
    Next I
 
    ' sichtbare Zeilen und deren Höhen ermitteln
    For I = .TopRow To .Rows - 1
      If .RowIsVisible(I) Then
        lCnt = lCnt + 1
        sngHeight = sngHeight + .RowHeight(I)
      End If
    Next I
 
    ' letzte sichtbare Zeile könnte nur tw. sichtbar sein
    ' --> wenn ja, dann nicht zählen
    If sngHeight > .Height - (2 * sngBorderCorr) Then lCnt = lCnt - 1
 
 
    RowsVisible = lCnt + IIf(WithFixedRows, .FixedRows, 0)
  End With
 
End Function

Viel Spass,
R@lf

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
scrollen im MSHFlexgrid per Code1.106cncandi25.07.06 23:20
Re: scrollen im MSHFlexgrid per Code820RalfH26.07.06 08:31

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2026 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel