Re: flexgrid display in VB6



> 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


.



Relevant Pages

  • Re: dynamically building template columns
    ... // apply custom formatting to data cells ... it's SortExpression to an empty string. ... Dim bfield As TemplateField = New TemplateField ... Private _templateType As ListItemType ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • RE: Error Trap not working
    ... Dim ColACount as Integer ... Dim ColAAddress As String, ColAName As String, ColBRange as String ... 'Code here that names the range of cells in Col. B as ColBRange ...
    (microsoft.public.excel.programming)
  • RE: Error Trap not working
    ... "Steve C" wrote: ... Dim ColAAddress As String, ColAName As String, ColBRange as String ... 'Code here that names the range of cells in Col. B as ColBRange ...
    (microsoft.public.excel.programming)
  • Re: Find string in Data
    ... possible to process the data from its source rather than putting it in cells ... Dim Contents As String ... Dim Fields() As String ...
    (microsoft.public.excel.programming)
  • Re: Print Grid
    ... Dim NewCell As String ... CommonDialog1.DialogTitle = "Save HTML Table" ... > Is there any way to adjust the time sheet printing...the Print Grid ...
    (microsoft.public.project.vba)