Solved

msflexgrid format

Posted on 2002-05-21
6
907 Views
Last Modified: 2008-02-01
here is my code..........

If Text1.Text <> "" Then
Dim search As String
Dim myconn
search = Text1.Text
search = Trim$(search)
Set myconn2 = New ADODB.Connection
myconn2.Open "Provider=Microsoft.JET.OLEDB.4.0;Persist Security Info=False;Data Source=c:\farebase\farebase.mdb"
Set myado2 = myconn2.Execute("SELECT farebase.from_1, farebase.to_1 From farebase where farebase.from_1 like '%" & search & "%'order by farebase.from_1 desc;")
Num = 0 + 0
 While Not myado2.EOF
    Num = Num + 1
    myado2.MoveNext
  Wend
End If
MsgBox Num

MSFlexGrid1.Cols = Num + 1
MSFlexGrid1.Rows = Num + 1

how do i set the headers of the columns???

i use this method to add into the cells...........

MSFlexGrid1.TextMatrix(1, 1) = "Hello EE"
MSFlexGrid1.TextMatrix(1, 2) = "Hello EE again"

what is the best way of putting data in, in this format..........


msflexgrid1 col1="text1" , col2="text2" etc etc

in one line, (it is easier for me to understand.

Also when somebosy clicks one specific row, i want the data in a hidden field to be usable..........


(ref ,  col1,   col2,   col3,   etc)
2   ,  name,  address,  tel,    fax
3   ,  fred,  123 road, 3456,   33333

the ref is hodden to the punter, but if they click the row it will bring up a msgbox with the ref num in...

I hope this makes sense, if it does not tell me.

Gavin (AKA Bolox)
0
Comment
Question by:bolox
  • 4
  • 2
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7023534
The headers are row zero so you can use:

MSFlexgrid1.TextMatrix(0,1) = "Column One"
MSFlexgrid1.TextMatrix(0,2) = "Column Two"

Use the Click event:

Private Sub MSFlexgrid1_Click()
  Msgbox MSFlexgrid1.TextMatrix(MSFlexgrid1.MouseRow,0)
End Sub

This bit I don't understand, can you clarify?

>> what is the best way of putting data in, in this format..........


msflexgrid1 col1="text1" , col2="text2" etc etc

in one line, (it is easier for me to understand.
0
 
LVL 1

Author Comment

by:bolox
ID: 7023565
actually i do not understand the last bit myself..........so i will not need that after all


the points are your already, for 10 extra points, how can i have the columns autosize to the contents.

for example, in one of my columns the results will always be one char in size and others are only 2 chars, where as the rest may need 20 chars???

if this is not easy, i will up the points

thanx

B

0
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 7023600
Well you are right it is not that easy but equally not impossible. This snippet will autosize every column of the flexgrid, you just need to adjust the for..next loop to handle the appropriate columns:

Private Sub Command2_Click()
   Dim aryWidths() As Double
   ReDim aryWidths(MSFlexGrid1.Cols - 1)
   For intRow = 1 To MSFlexGrid1.Rows - 1
       For intCol = 0 To MSFlexGrid1.Cols - 1
           If Form1.TextWidth(MSFlexGrid1.TextMatrix(intRow, intCol)) > aryWidths(intCol) Then
               aryWidths(intCol) = Form1.TextWidth(MSFlexGrid1.TextMatrix(intRow, intCol))
           End If
       Next
   Next
   For intCol = 0 To MSFlexGrid1.Cols - 1
       MSFlexGrid1.ColWidth(intCol) = aryWidths(intCol) + 100
   Next
End Sub
0
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!

 
LVL 1

Author Comment

by:bolox
ID: 7023609
you are a star
0
 
LVL 1

Author Comment

by:bolox
ID: 7023611
well deserved points,

speak to ya soon

Gavin
0
 
LVL 1

Author Comment

by:bolox
ID: 7023651
how could i preset the columns to a certain size, knowing there are 5 cols for example,

so, col1 is X big
    col2 is Y  big
   etc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 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