Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

problem scrolling a msFlexGrid control

Posted on 2004-04-22
3
Medium Priority
?
608 Views
Last Modified: 2013-12-26
Hi, I wanted to be able to edit the first three colums of a MSFlexGrid control but also to fix these colums when scrolling to the right (they contain descriptions for the row).
So I coded this in the MSFlexGrid1_Scroll event:
<vb>
with msflexGrid1
If .ColIsVisible(6) Then 'when column 6 appears it means
                                  'that there a was a shift
        .FixedCols = 3
Else
        .FixedCols = 0
End If
end with
</vb>

but now I cannot scroll vertically to the bottom of the grid.
I just can get to  row .Rows-2

Any clue?  Thank you very much.

rr.
0
Comment
Question by:rrgw
  • 2
3 Comments
 
LVL 5

Expert Comment

by:amit1978
ID: 10897027
Hi,

What i am getting is u have control (Text Box ) on first three col on each row. Now u want as user scroll it will also scroll with the appropriate col.


Let me correct if i am mistaking so we continue.

Amit Jian
0
 
LVL 11

Accepted Solution

by:
dbrckovi earned 300 total points
ID: 10898179
Try this:

 - start new project
 - create MSFlexGrid and a CheckBox
 - paste this code:
--------------------------------------------------
Private Sub Check1_Click()
    If Check1.Value = 1 Then                    'Change flexgrid appearance to edit mode
        MSFlexGrid1.FixedCols = 0
        For X = 0 To 2
            MSFlexGrid1.Col = X
            For Y = MSFlexGrid1.FixedRows To MSFlexGrid1.Rows - 1
                MSFlexGrid1.Row = Y
                MSFlexGrid1.CellBackColor = vbButtonFace
            Next Y
        Next X
    Else                                        'Change appearance back to normal
        MSFlexGrid1.FixedCols = 3
        For X = 0 To 2
            MSFlexGrid1.Col = X
            For Y = MSFlexGrid1.FixedRows To MSFlexGrid1.Rows - 1
                MSFlexGrid1.Row = Y
                MSFlexGrid1.CellBackColor = vbButtonFace
            Next Y
        Next X
    End If
End Sub

Private Sub Form_Load()                       'Some initialisation
    MSFlexGrid1.Cols = 10
    MSFlexGrid1.Rows = 10
    MSFlexGrid1.FixedCols = 3
    Check1.Caption = "Edit mode"
    Check1.Value = 0
End Sub

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
    If Check1.Value = 0 Then Exit Sub                     'Ignore keypresses if not in edit mode
   
    If KeyAscii = vbKeyBack Then                          'Delete last character a cell
        If Len(MSFlexGrid1.Text) > 0 Then MSFlexGrid1.Text = Left(MSFlexGrid1.Text, Len(MSFlexGrid1.Text) - 1)
        GoTo CalculateWidth
    End If
       
    If KeyAscii = 13 Then                                   'If enter is pressed jump to cell to the right or jump to next row if this is the last cell in current row
        If MSFlexGrid1.Col = MSFlexGrid1.Cols - 1 Then
            If MSFlexGrid1.Row = MSFlexGrid1.Rows - 1 Then
            Else
                MSFlexGrid1.Row = MSFlexGrid1.Row + 1
                MSFlexGrid1.RowSel = 0
                MSFlexGrid1.Col = 0
                MSFlexGrid1.ColSel = MSFlexGrid1.Col
            End If
        Else
            MSFlexGrid1.Col = MSFlexGrid1.Col + 1
            MSFlexGrid1.ColSel = MSFlexGrid1.Col
        End If
        MSFlexGrid1.TopRow = MSFlexGrid1.Row
        MSFlexGrid1.LeftCol = MSFlexGrid1.Col
        Exit Sub
    End If
   
    MSFlexGrid1.Text = MSFlexGrid1.Text & Chr(KeyAscii)     'Add the character to current cell
   
CalculateWidth:                                             'Calculate new width of current collumn
    wasrow = MSFlexGrid1.Row
    LargestWidth = 0
    For X = 0 To MSFlexGrid1.Cols - 1
        MSFlexGrid1.Row = X
        If (Me.TextWidth(MSFlexGrid1.Text) + 200) > LargestWidth Then LargestWidth = (Me.TextWidth(MSFlexGrid1.Text) + 200)
    Next X
    MSFlexGrid1.ColWidth(MSFlexGrid1.Col) = LargestWidth
    MSFlexGrid1.Row = wasrow
End Sub
--------------------------------------------------
0
 
LVL 11

Expert Comment

by:dbrckovi
ID: 10898228
To implement this into an existing Flex Grid it should be enough just to create Check1 and paste     Check1_Click()      and      MSFlexGrid1_KeyPress     subroutines (without Form_Load), but it depends on what you
already have in your project.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question