Solved

DataGrid  row height resizing issues

Posted on 2001-09-05
12
2,440 Views
Last Modified: 2012-06-27
I currently have a DataGrid populated by a MSAccess backend. How can I have the row heights automatically adjust to fit the amount of information in a particular record. For example, if a certain record has a memo field and a lot of text, I want the wordwrap on and the height of the cell to expand so that all the text is visible w/o any scrollage. Is this at all feasible? Essentially, I want the row heights to adjust on the fly based on how much information is in the database.
0
Comment
Question by:RTDesi
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6457422
Not feasible with the datagrid. You can only change the rowheight of all rows using this grid component. The Flexgrid and also third-party grid controls will have this feature but it is not available to the DBGrid or DataGrid controls.
0
 

Author Comment

by:RTDesi
ID: 6457534
I also need update/delete capabilities, and to my knowledge, these are not available in the Flexgrid. Is it feasible to get BOTH adjustable row heights and update/delete capabilities in one control?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 6457964
We use the Sheridan or now Infragistics grids.  The ones we use allow update/delete capability but all rows are the same height.  They do have other grids available but we don't have them.

good luck
mlmcc
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6460195
The Videosoft Flexgrid or Apex TrueDBGrid both from http://www.componentone.com or the Janus GridEx from http://www.janus.com offer both feature sets, in-cell editability combined with data bound operation and similar flexibility to the flexgrid. In fact the intrinsic controls are cut-down versions of some of these commercial ones.
0
 
LVL 2

Expert Comment

by:rogerhammond
ID: 6863468
Use the MSHFlexGrid control.  To get dynamic and individual row height scaling...you work out what you want to scale...this example uses a Notes history list, where the comments can be multiple lines.

Create a label on your form, set wordwrap to true and make the width of the label the same as the field that you want to scale your row to (if you have multiple fields that you need to check for your min row height, then you just have to check each field separately and set the label width to suit.  Make the label non-visible.  Then, in your code, do something like this

    adoCmd.CommandText = "sp_getCustomerNotes"
    adoCmd.CommandType = adCmdStoredProc
    adoCmd.Parameters.Refresh
    adoCmd.Parameters("@CustomerID") = frmMain.AccNo.Text
    Set rst = adoCmd.Execute
   
    With rst
        While Not .EOF
            lstNotes.AddItem Format(!NoteDate, "dd-mmm-yy hh:nn") & vbTab & _
            !NoteText & vbTab & _
            !NoteUser
           
            lstNotes.RowData(lstNotes.Rows - 1) = !PK_Notes

-- this is the part that determines your row height.
-- the font size of your label also has to match the
-- font you use in the FlexGrid.
-- I also add another 40 twips to pack it out nicely.

            Label1.Caption = !NoteText
            lstNotes.RowHeight(lstNotes.Rows - 1) = Label1.Height + 40
           
            .MoveNext
        Wend
    End With


Works a treat.

This was actually adapted from a tip on how to determine text width from the site... http://cuinl.tripod.com/tips-and-tricks-all.htm

Cheers
Roger
0
 
LVL 2

Expert Comment

by:rogerhammond
ID: 6863474
or MSFlexGrid (which I use...MSDN seem to use the two interchangeably)
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 43

Expert Comment

by:TimCottee
ID: 6863824
rogerhammond, you are not a new member and as such are aware of the guidelines. I am posting a CS question to reject your proposed answer as this appears to be an otherwise abandoned question.

If the questioner returns, please reject this answer at this time.
0
 
LVL 2

Expert Comment

by:rogerhammond
ID: 6866160
I see it as a valid answer...the only part I have left out is the update/delete issue which is addressed by making the control be dynamically built each time there is an event that requires a database change in the back end.

The original question states that it only wants to be able to resize individual rows based on the contents of data in that row.  This is a question I wanted an answer to as well.  And the answer is that the FlexGrid does indeed do what it asked and the code I have provided shows you how to calculate what height the row needs to be and how to set the height of the row.

It appears to address the issue completely.  
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6867586
It may well be a valid answer, however as has already been identified, the flexgrid doesn't provide update/delete capabilities. Which the suggested commercial grids do. Your code could be adapted very easily to one of these products, especially the vsflexgrid as this is the grid that the flexgrid was based on (cut-down functionality though). Nevertheless the protocol in this TA is to post comments rather than answers. Especially in a "dead" question like this, it appears to be more an attempt to gain points than to offer genuine help. Please don't take that the wrong way.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6867735
Finalized today by EE Moderator
0
 
LVL 2

Expert Comment

by:rogerhammond
ID: 6875022
The original question is phrased...

<quote>
I currently have a DataGrid populated by a MSAccess backend. How can I have the row heights automatically
adjust to fit the amount of information in a particular record. For example, if a certain record has
a memo field and a lot of text, I want the wordwrap on and the height of the cell to expand so that
all the text is visible w/o any scrollage. Is this at all feasible? Essentially, I want the row heights
to adjust on the fly based on how much information is in the database.
</quote>

Update delete is not mentioned in the actual question, he does mention it later, but didn't update the question to include this.  Anyway, I've played with controls that connect directly to the database - and this results in requiring a connection per control, which is really wasteful if you have 100 people on the floor using the same app...last app we had used 3 connections per person.  

And you've obviously looked at my profile, so you can clearly see that I don't need points...I have more points than I know what to do with.  I was simply looking for a question posting similar to what I was looking for and found only this unanswered one.  I didn't want to use any 3rd party controls, just the base Microsoft ones - so I figured that I would have to work it out for myself.

The answer proposed answers the text of the MAIN question.  I don't care that I get no points this time, just that the next person who searchs like me will get what they're looking for.

0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6929056
Points for rogerhammond -> qid=20286636  
Please comment in this TA at the QID above.  Sorry for the delay, but I am swamped with backlog items.

For your contributions to this question with thanks.
:)
Moondancer - EE Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

707 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

12 Experts available now in Live!

Get 1:1 Help Now