Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which control to use? Like a datagrid but different 1

Status
Not open for further replies.

Rechmali

Programmer
Jun 14, 2004
17
GB
Ok, I am feeling more than a little dim!

I am trying to set up a form which will display a number of records and allow the user to select a record. I have previously used a DataGrid which comes close, however, what it doesn’t appear to do is cater for a lot of text in one of the fields.

The effect I am after is like what would happen in a word table with the row height/wrapping automatically.

I hope this is clear and that someone can help.

Many thanks in anticipation.

Cheers
Chris
 
Have you tried the MSFlexGrid control I havent used it but it has a cell.wordwrap property.
 
Here is a start of a direction that you could take with either a MSFlexGrid or the MSHFlexGrid. This paticular code uses the MSHFlexGrid. It is not complete by any means but it can give you a concept of what you can do. If you have specific questions you can post back here...

Code:
Option Explicit

Private Sub Form_Load()
    Dim rs As ADODB.Recordset
   
    Set rs = New ADODB.Recordset
   
    With MSHFlexGrid1
        .Left = 0
        .Top = 0
        .Width = Me.Width
        .Height = Me.Height
    End With
        
    With rs
        .ActiveConnection = Nothing
        .Fields.Append "MyNumber", adInteger
        .Fields.Append "TestField", adVarChar, 5000
        .Fields.Append "TestField2", adVarChar, 10
        
        .Open
    End With
    
    rs.AddNew
    rs("MyNumber").Value = "1"
    rs("TestField").Value = "JFSD:LFKJSFDJLSDf sdkfj; sfs sdfsdjf " & _
        vbCrLf & "KFJK:DJF:LJSDFdkljf; sfdj s;fjsdkf sd;fj sdf;sajfsdkfjsdlfkj " & _
        vbCrLf & "KJFLK:SJD:FDLFKJS:FKSJ SDFKJ :SDFKJ SSDLFKJ SDFKJ SDFJDSL:FK "
    rs("TestField2").Value = "Test"
    rs.Update
    
    Set Me.MSHFlexGrid1.DataSource = rs
    
    Me.MSHFlexGrid1.ColWidth(2) = TextWidth(rs("TestField"))
    Me.MSHFlexGrid1.RowHeight(1) = TextHeight(rs("TestField"))
    

End Sub

Private Sub Form_Resize()
    With MSHFlexGrid1
        .Left = 0
        .Top = 0
        .Width = Me.Width
        .Height = Me.Height
    End With
End Sub

Put the above code in a form and add a MSHFlexGrid control to the form and then run the program.
 
Hey guys,

Thank you so much for your help.

I am going to have a play and see if we can get to where i am after.

bjd4jc, have a star for your most kind plug and play code :)

Cheers

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top