Solved

VB4.0/16 bit/Access 2.0/DBGrid

Posted on 1997-06-15
7
176 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
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

 

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

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now