Solved

msflexgrid format

Posted on 2002-05-21
6
894 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:bolox
Comment Utility
you are a star
0
 
LVL 1

Author Comment

by:bolox
Comment Utility
well deserved points,

speak to ya soon

Gavin
0
 
LVL 1

Author Comment

by:bolox
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now