Solved

msflexgrid format

Posted on 2002-05-21
6
920 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 5 hours left to enroll

636 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