Solved

datagrid vs MsFlexgrid

Posted on 2004-04-05
9
53,459 Views
Last Modified: 2013-12-25
Hello experts,

I have a couple of questions on MsFlexgrid, I have been using Datagrid, and need to swap over, so the questions;-

1.) Is it possible to do a fullrowselect in MsFlexgrid.
2.) Is there an AllowArrows = True method for MsFlexgrid

If these are possible, how do I do this?

thank you
0
Comment
Question by:claracruz
[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
9 Comments
 
LVL 9

Accepted Solution

by:
dancebert earned 100 total points
ID: 10761617
1 is true, if I understand your question.  I have code that does the following: 1) click on fixed column (column # 0) and the row is highlighted.  2) Click on fixed column in a highlighted row and the row highlighting is removed.  3) Highlight one row, press shift and click on the fixed column of another row and all the rows in between are highlighted.  In all three cases, once a row is highlighted, clicking on any cell that is not in the fixed column will turn off all highlighting.  

If this is what you are trying to do, I can post a working example.
0
 
LVL 18

Assisted Solution

by:Sethi
Sethi earned 25 total points
ID: 10762314
1) True. It's possible
2) False. Not possible as there is not corresponding property or method for this.
0
 
LVL 4

Author Comment

by:claracruz
ID: 10763973
yes please, post a working example for a fullrowselect.
And also since 'AllowArrow = true' is not available in MsFlexgrid, is it at all possible for a user to move from one row to the next row down, without using the mouse.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 5

Expert Comment

by:amit1978
ID: 10764142
Hi claracruz,

FlexGrid is much batter option then dbgrid as its static and no addition and deletion is not possible and ya also no updation. but ......but .......every thing is posible in flexgrid but u have to code for that thats the difference between flexgrid and dbgrid u there is not requirement of coding .

if u required code then may be i can help u.....


Amit Jain
0
 
LVL 4

Author Comment

by:claracruz
ID: 10764957
yes please, that is exactly what I need, the code for the methods I listed.

thank you
0
 
LVL 9

Assisted Solution

by:dancebert
dancebert earned 100 total points
ID: 10766782
Add a MSFlexGrid to a form, copy the following code into it.  Click on fixed column (column 0) to toggle row highlight.  Also supports Shift-Click and Ctrl-Click, which acts the same way as those keys in Windows Explorer.

==================  

Private m_IsOnFixedPart As Boolean
Private m_IsZeroRow As Boolean


Private Sub Form_Load()
' Begin sample grid setup code
            With MSFlexGrid1
                .Cols = 4
                .Rows = 10
                .FixedCols = 1
                .FixedRows = 1

                .Row = 0
                .TextMatrix(0, 1) = "Col1"
                .TextMatrix(0, 2) = "Col2"
                .TextMatrix(0, 3) = "Col3"

                Dim ii As Long
                For ii = 1 To 9
                    .TextMatrix(ii, 0) = ii
                    .TextMatrix(ii, 1) = CStr(CInt(Rnd * 10000))
                    .TextMatrix(ii, 2) = Chr(CInt(Asc(Rnd * 122) + 65))
                    .TextMatrix(ii, 3) = DateAdd("d", CInt(Rnd * 100), Date)
                Next ii

                ' Size the fixed column.
                .ColWidth(0) = 400
                .ColAlignment(0) = flexAlignCenterCenter
            End With
' End sample grid setup code at end.

End Sub

Private Sub ToggleSelect()
 'Toggle the select in the clicked row
    With MSFlexGrid1
        .Row = .MouseRow
        .FillStyle = flexFillRepeat
        .Col = .FixedCols
       
        .ColSel = .Cols - 1
        .HighLight = flexHighlightNever
        If .CellBackColor = vbHighlight Then
            .CellBackColor = .BackColor
            .CellForeColor = .ForeColor
        Else
            .CellBackColor = vbHighlight
            .CellForeColor = vbHighlightText
        End If
    End With
End Sub

Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    ' Are we on fixed column?  If so, highlight row(s)
   
    With MSFlexGrid1
        If .Rows = 0 And .Cols = 0 Then
            Exit Sub
        End If
       
        ' After deselecting rows, need these to get back to original cell
        Dim lRowOriginal As Long: lRowOriginal = .MouseRow
        Dim lColOriginal As Long: lColOriginal = .MouseCol
   
        ' Don't understand this, the code was downloaded.
        Dim l As Long
        Dim lWidth As Long
        For l = 0 To .Cols - 1
            If .ColIsVisible(l) Then
                lWidth = lWidth + .ColWidth(l)
            End If
        Next
       
        If .RowHeightMin = 0 Then
            m_IsOnFixedPart = (x < .ColWidth(0)) Or _
                       (x > lWidth) Or _
                       (y < .RowHeight(0))
        Else
            m_IsOnFixedPart = (x < .ColWidth(0)) Or _
                       (x > lWidth) Or _
                       (y < .RowHeight(0)) Or _
                       (y > .Rows * .RowHeightMin)
        End If
                       
        m_IsZeroRow = (.RowHeight(0) >= y)
       
       
        '' Highlighting
        If Not m_IsOnFixedPart Or m_IsZeroRow Then
            DeselectAllRows
            .Row = lRowOriginal
            .Col = lColOriginal
        Else
            If (Shift And vbShiftMask) = vbShiftMask Then
                SelectContigious 'Select from the current row to the clicked row
            ElseIf (Shift And vbCtrlMask) = vbCtrlMask Then
                ToggleSelect  'Toggle the select in the clicked row
            Else
                 DeselectAllRows
               
                'select clicked row
                 .RowSel = .Row
                 .ColSel = .Cols - 1
                .CellBackColor = vbHighlight
                .CellForeColor = vbHighlightText

            End If  '' If (Shift And vbShiftMask) = vbShiftMask Then
        End If  '' If Not m_IsOnFixedPart Or m_IsZeroRow Then
    End With

End Sub

Private Sub DeselectAllRows()
   
    Dim lRowOriginal As Long
    With MSFlexGrid1
        lRowOriginal = .Row
        .Row = .FixedRows
        .Col = .FixedCols
        .RowSel = .Rows - 1
        .ColSel = .Cols - 1
        .FillStyle = flexFillRepeat
       
        .HighLight = flexHighlightNever
        .CellBackColor = .BackColor
        .CellForeColor = .ForeColor
        .Row = lRowOriginal
        .ColSel = .Cols - 1
    End With

End Sub

Private Sub SelectContigious()
'Select from the current row to the clicked row
    Dim lRow As Long
    Dim lMouseRow As Long

    With MSFlexGrid1
        lRow = .Row
        lMouseRow = .MouseRow
        .FillStyle = flexFillRepeat
        .Row = lRow
        .Col = .FixedCols
        .RowSel = lMouseRow
        .ColSel = .Cols - 1
        .HighLight = flexHighlightNever
        .CellBackColor = vbHighlight
        .CellForeColor = vbHighlightText
    End With
End Sub

0
 
LVL 4

Author Comment

by:claracruz
ID: 10769648
I am sorry but I don't think this is what I need.

I have an SQL query that looks like this;

strDates = "SELECT [First Name], [Last Name], Players.[Date Of Birth], WHERE [Course Code]= '" & .DataGrid1.Columns(0) & "'    

what would be the equivalent of -  '" & .DataGrid1.Columns(0) & "'- when using an MsFlexgrid.

My other question is this:-
With the datagrid, I can move from one row to the next (and mimic the datagrid's click event ) using up or down arrows (and NOT the mouse) by setting AllowArrow property to "True", How do I do this with the MsFlexgrid.
0
 
LVL 4

Author Comment

by:claracruz
ID: 10773020
My question has been answered by RIMVIS,  posted at;-

(http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20946101.html)

1)
To get value of MSFlexGrid cell, use TextMatrix property
TextMatrix(rowindex, colindex) [=string]

To get current row and columd, use Row and Col properties respectively.

So, value of current cell wil be MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, MSFlexGrid1.Col)

2)
You can navigate in flex grid using arrow keys without any additional code.
If you want to have entire row selected, set SelectionMode to 1 (select by row)


But thank you for all your contributions...

0
 

Expert Comment

by:R_K_T_ASHOKA
ID: 10842921
Hai,
     I have done a tutorial on how to use Flexgrid as Datagrid you can get it on the folowing link.

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=42344&lngWId=1

Inform me if it is usefull.

Bye Bye,
R.K.T. ASHOKA.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

733 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