Link to home
Start Free TrialLog in
Avatar of Sheritlw
SheritlwFlag for United States of America

asked on

Enumerate Grids

I have a form that has 10 separate fpSpreads/grids on it.  
Each grid will get filled in a class.
What I would like to do is enumerate each grid and be able to define it as the actual grid.
This is what I usually declare it as when I need to use an actual grid.
Private mfpGrd As FarPoint.Win.Spread.FpSpread
How can enumerate these grids and use it in my application?
Please provide example code, clicking on links crashes my IE.
Thanks
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

The question is not very clear. You have a Windows Forms app where you use a number of grids. You need to access each grid right?
Avatar of Sheritlw

ASKER

I wanted to be able within code be able to use the intelliscence to know what the grid name is, but I also need to pass the grid to a class.
I have finished the form I was working on and just created some properties and had to hard code the names of the grids everywhere.
I am preparing another form, actually a usercontrol and would love to be able to have the names and grids easy to assess.
I created a question named "Copy Everything from TabPage1 to tabpage2" but the answer I got was for VB 6, not VB 2008 or VB.Net.
You have helped me before and have always provided great solutions.  If you want to work with me, I will be creating a lot of questions.
Thanks
Sheri
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How would I go about creating a collection?
Thanks
Well I read all  the articles and I understand a lot of it.  I used to use a lot  of  control collections  in VB 6 but need a sample that will create a collection of my fpSpread grids  in VB2008.
Thanks
You need to create the grids yourself. Configure the grids and add them to the collection by using the add method.
Yes, I know.   I  have already created all  the grids and I know about the add method, I just need to know  what the  format  is for creating a collection that it knows each item  is a spread so I can use the properties etc. of  the fpSpread.
In enumeration, you can't define a control type, that's why I thought your idea for a collection would be great.
I  need to know how to define it.  but is a collection layed out like an enum???
I started with  this  declaration...

Private FGrd As FarPoint.Win.Spread.FpSpread.ControlCollection
Collect as fGrd  ???? how do I get started????
Thanks
Well I finally found an example on  the net.  
Thank you for steering me towards collections... pretty easy in  .Net

The following is what I am using...

    Public FGrd As New Collection

    Private Sub frmRaces_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AddToCollection()
        FormatHeaderCells()

    End Sub

    Private Sub AddToCollection()

        With FGrd

            .Add(Me.fpGrdEngines5)
            .Add(Me.fpGrdFront5)
            .Add(Me.fpGrdGearing5)
            .Add(Me.fpGrdLFront5)
            .Add(Me.fpGrdLRear5)
            .Add(Me.fpGrdRear5)
            .Add(Me.fpGrdRFront5)
            .Add(Me.fpGrdRRear5)
            .Add(Me.fpGrdWings5)

        End With
    End Sub
    Private Sub FormatHeaderCells()
        Dim sv As FarPoint.Win.Spread.SheetView
        Dim cnt As FarPoint.Win.Spread.FpSpread

        For Each cnt In FGrd

            cnt.ActiveSheet.ColumnHeader.Visible = True

            cnt.ActiveSheet.VisualStyles = FarPoint.Win.VisualStyles.Off
            cnt.ActiveSheet.ColumnHeader.RowCount = 1
            sv = cnt.ActiveSheet
            sv.AddColumnHeaderSpanCell(0, 1, 1, 2)
            sv.Columns(1, 2).Label = ReturnLabel(cnt.Name)
            sv.ColumnHeader.Cells(0, 1, 0, 2).BackColor = ReturnColor(cnt.Name)
            If InStr(cnt.Name, "fpGrdFront") Or InStr(cnt.Name, "fpGrdRear") Then
                sv.ColumnHeader.Cells(0, 1, 0, 2).Font = New Font(cnt.Font.Name, 6.5, FontStyle.Bold)
            Else
                sv.ColumnHeader.Cells(0, 1, 0, 2).Font = New Font(cnt.Font.Name, 8, FontStyle.Bold)
            End If

        Next cnt


    End Sub
Glad that my idea was helpful to you.