Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATE msflexgrid as in xlsx file 2

sal21

Programmer
Apr 26, 2004
476
IT
Normally i use to create a msflexgrid:

Me.MSFlexGrid1.FormatString = "<STRADA|^PR|<COMUNE-LOCALITA'|^CAP|^LAT|^LNG|<STRADA"

now i need to create a msflexgrid with a union of 5 columns from the second col...
Possible?

note:
the merged cell have lenght 1000 and the 5 coluimn have lenght 200, center all meged cell and each column
 

Attachments

  • Immagine.jpg
    Immagine.jpg
    95.9 KB · Views: 5
Last edited:
>a msflexgrid with a union of 5 columns

I don't believe you can create merges/unions using formatstring
 
for strongm.

my test code:

Rich (BB code):
Private Sub UNIONE_CELLE()

'flexAlignLeftTop 0 The column content is aligned left, top.
'flexAlignLeftCenter 1 Default for strings. The column content is aligned left, center.
'flexAlignLeftBottom 2 The column content is aligned left, bottom.
'flexAlignCenterTop 3 The column content is aligned center, top.
'flexAlignCenterCenter 4 The column content is aligned center, center.
'flexAlignCenterBottom 5 The column content is aligned center, bottom.
'flexAlignRightTop 6 The column content is aligned right, top.
'flexAlignRightCenter 7 Default for numbers. The column content is aligned right, center.
'flexAlignRightBottom 8 The column content is aligned right, bottom.
'flexAlignGeneral 9 The column content is of general alignment. This is "left, center" for strings and "right, center" for numbers.

    Dim I As Integer
   
    With Me.MSFlexGrid1
        .Redraw = False
        For I = 2 To 6
            .MergeCells = flexMergeFree
            .ColAlignment(2) = flexAlignCenterCenter
            .TextMatrix(0, I) = "BARI"
            .MergeRow(0) = True
        Next
        .Redraw = True
    End With

End Sub

but i need for all city as in xcel sheet.


BARI
CAGLIARI
FIRENZE
GENOVA
MILANO
NAPOLI
PALERMO
ROMA
TORINO
VENZIA
 
Rich (BB code):
Public Sub Example()
    Dim lp As Long
    Dim arySource() As String
    Dim colloop As Long
    Dim colpos As Long
    Dim lp2 As Long
    
    arySource = Split("BARI,CAGLIARI,FIRENZE,GENOVA,MILANO,NAPOLI,PALERMO,ROMA,TORINO,VENZIA", ",")
    
    colpos = 2
    colloop = 5
    For lp = 0 To UBound(arySource)
        colpos = 2 + lp * colloop
        For lp2 = 0 To colloop - 1
           ' Debug.Print arySource(lp)
            
            With Me.MSFlexGrid1
                .ColWidth(colpos + lp2) = 250
                .TextMatrix(0, colpos + lp2) = arySource(lp)
            End With
        Next
    Next
    
    ' only need to do this once
    Me.MSFlexGrid1.MergeCells = flexMergeFree
    Me.MSFlexGrid1.MergeRow(0) = True
    
End Sub
 
FOR strongm.
im sorry but new city named NAZIONALE in Sub Example

arySource = Split("BARI,CAGLIARI,FIRENZE,GENOVA,MILANO,NAPOLI,PALERMO,ROMA,TORINO,VENZIA,NAZIONALE", ",")
 
My code takes no account of how many columns the flexgrid actually has, It will fail if there are not enough columns available. So just add a few more (either at design time or run time)
 

Part and Inventory Search

Sponsor

Back
Top