[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

VB4.0/16 bit/Access 2.0/DBGrid

I am creating a user interface to easily search an Access 2.0 database and display only a few fields from one table in a DBGrid that is bound to a data control.  One of the fields contains many lines of text.  How do I wrap the text in that column of the grid so the user can see it all at once without having to horizontally scroll within the cell?  It seems like this should be fairly easy, but I've tried everthing I can think of.  Can you please help?
0
STKeith
Asked:
STKeith
  • 4
  • 2
1 Solution
 
BBCCommented:
Maybe you should use a function as a result for that special column. The function itself should do the word-wrapping an insert an LF/CR after lets say 30 chars.
0
 
twardCommented:
Along with what BBC said I believe you also have to adjust the RowHeight for each line.  At least I know it is this way with the regular GRID, after putting in the CR (was all I needed) I then had to adjust the RowHeight to be equal to the height of the text*the number of lines of text.
0
 
STKeithAuthor Commented:
Edited text of question
0
Industry Leaders: 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!

 
STKeithAuthor Commented:
Adjusted points to 100
0
 
STKeithAuthor Commented:
I have tried adjusting the RowHeight, but the text does not continue to the next line of the cell.  According to the online help for DBGrid, the text should automatically wrap to the next line but its not.  I'm afraid that if I use a function to retreive and modify all of the text for that column that it will slow things down too much.  Is there anyway around this?
0
 
twardCommented:
As far as I know there is not a way around this.  The on-line help for the GRID says the same thing but I to found this not to be true so I simply go into the string and put a CR in the string several times to split the string up where I needed to.  This might help, it is some word wrap code that someone gave to me, this puts a CRLF pair but it could easily be changed to put just a CR.

Public Function WordWrap(St$, Length As Integer) As String

'-- This function converts raw text into CRLF delimited lines.
    Dim Cr$, CrLF$, NextLine$, Text$
    Dim L, S, C As Integer
    Dim DoneOnce As Boolean

    Length = Length + 1
    St$ = Trim$(St$)
    Cr$ = Chr$(13)
    CrLF$ = Chr$(13) & Chr$(10)

    Do
        L = Len(NextLine$)
        S = InStr(St$, " ")
        C = InStr(St$, Cr$)

        If C Then
            If L + C <= Length Then
                Text$ = Text$ & NextLine$ & Left$(St$, C)
                NextLine$ = ""
                St$ = Mid$(St$, C + 1)
                St$ = Mid$(St$, C + 1)
                GoTo LoopHere
            End If
        End If
        If S Then
            If L + S <= Length Then
                DoneOnce = True
                NextLine$ = NextLine$ & Left$(St$, S)
                St$ = Mid$(St$, S + 1)
            ElseIf S > Length Then
                Text$ = Text$ & CrLF$ & Left$(St$, Length)
                St$ = Mid$(St$, Length + 1)
            Else
                Text$ = Text$ & NextLine$ & CrLF$
                NextLine$ = ""
            End If
        Else
            If L Then
                If L + Len(St$) > Length Then
                    Text$ = Text$ & NextLine$ & CrLF$ & St$ & CrLF$
                Else
                    Text$ = Text$ & NextLine$ & St$ & CrLF$
                End If
            Else
                Text$ = Text$ & St$ & CrLF$
            End If
            Exit Do
        End If

LoopHere:

    Loop

    WordWrap = Text$

End Function
0
 
STKeithAuthor Commented:
Thanks tward.  This looks like it will do the trick.
0

Featured Post

Industry Leaders: 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!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now