Solved

VB4.0/16 bit/Access 2.0/DBGrid

Posted on 1997-06-15
7
179 Views
Last Modified: 2012-08-14
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
Comment
Question by:STKeith
  • 4
  • 2
7 Comments
 
LVL 1

Expert Comment

by:BBC
ID: 1427285
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
 
LVL 7

Accepted Solution

by:
tward earned 100 total points
ID: 1427286
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
 

Author Comment

by:STKeith
ID: 1427287
Edited text of question
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:STKeith
ID: 1427288
Adjusted points to 100
0
 

Author Comment

by:STKeith
ID: 1427289
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
 
LVL 7

Expert Comment

by:tward
ID: 1427290
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
 

Author Comment

by:STKeith
ID: 1427291
Thanks tward.  This looks like it will do the trick.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

776 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