Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataGrid  row height resizing issues

Posted on 2001-09-05
12
Medium Priority
?
2,640 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
[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
  • 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 101

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 43

Accepted Solution

by:
TimCottee earned 200 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
 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 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