?
Solved

problem scrolling a msFlexGrid control

Posted on 2004-04-22
3
Medium Priority
?
606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

777 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