Re: flexgrid display in VB6
- From: "Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Oct 2005 17:46:30 -0400
> more information:i want when first setting a datasource to the
grid
> have it displayed horizontally, ie..
> Col1 Abc
> Col2 1.23
> Col3 23/05/98
>
> not after a user selects it. i only ever get one row of data for
this
> particular grid.
>
> when i put your code behind a select, it gets a subscript out of
range.
> it's a problem with the split function, where i think the
delimter for
> each cell is not being picked up, you have vbtab here, is that
what it
> should be for reading the various grid cells?
I'm not sure what you mean by your statement "i only ever get one
row of data for this particular grid". Anyway, you don't have to
wait for your user to select the cells, you can select the cells
in code if you know the what the extent of the selection should
be. Here is my code, modified to select the first 3 columns and
first 2 rows, and invert them as you wanted...
Dim X As Long
Dim Y As Long
Dim NumOfRows As Long
Dim NumOfCols As Long
Dim ClippedText As String
Dim RowData() As String
Dim ColData() As String
With MSFlexGrid1
.Row = 0
.Col = 0
.RowSel = 1
.ColSel = 2
NumOfRows = .RowSel - .Row + 1
NumOfCols = .ColSel - .Col + 1
ClippedText = .Clip
RowData = Split(ClippedText, vbCr)
.Clear
For X = 0 To NumOfRows - 1
ColData = Split(RowData(X), vbTab)
For Y = 0 To NumOfCols - 1
.TextMatrix(Y, X) = ColData(Y)
Next
Next
End With
The key to selecting contiguous cells in code is to use the Row,
Col, RowSel and ColSel properties; it is important to note that
Row and Col should always be set before RowSel and ColSel.
Rick
.
- Follow-Ups:
- Re: flexgrid display in VB6
- From: stromberg45
- Re: flexgrid display in VB6
- References:
- flexgrid display in VB6
- From: stromberg45
- Re: flexgrid display in VB6
- From: Rick Rothstein [MVP - Visual Basic]
- Re: flexgrid display in VB6
- From: stromberg45
- flexgrid display in VB6
- Prev by Date: Re: Multiple ListBox ScrollBar Coordination
- Next by Date: Clipboard font information
- Previous by thread: Re: flexgrid display in VB6
- Next by thread: Re: flexgrid display in VB6
- Index(es):
Relevant Pages
|