?
Solved

VB4.0/16 bit/Access 2.0/DBGrid

Posted on 1997-06-15
7
Medium Priority
?
200 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
[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
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 400 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
Technology Partners: 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!

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

764 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