[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2677
  • Last Modified:

DataGrid row height resizing issues

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
RTDesi
Asked:
RTDesi
  • 4
  • 4
  • 2
  • +2
1 Solution
 
TimCotteeCommented:
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
 
RTDesiAuthor Commented:
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
 
mlmccCommented:
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
Industry Leaders: 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!

 
TimCotteeCommented:
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
 
rogerhammondCommented:
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
 
rogerhammondCommented:
or MSFlexGrid (which I use...MSDN seem to use the two interchangeably)
0
 
TimCotteeCommented:
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
 
rogerhammondCommented:
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
 
TimCotteeCommented:
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
 
MoondancerCommented:
Finalized today by EE Moderator
0
 
rogerhammondCommented:
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
 
MoondancerCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now