We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

setting individual row heights in data grid

Thread ID:

Created:

Updated:

Platform:

Replies:

14635 Jun 1,2004 03:46 PM UTC Jun 11,2004 01:22 PM UTC WinForms 4
loading
Tags: FAQ
Jurg Hinderling
Asked On June 1, 2004 03:46 PM UTC

I have read and successfully tried the reflection based methodology to set the row heights in a data grid. However, when one uses a class derived from DataGrid reflection can't get to the private objects in the base class anymore as inheritance only propagates non-private items and hence property "DataGridRows" or method "get_DataGridRows" is not accessible through reflection anymore from the derived class. Has anyone seen a method that works even in a derived class?

Jurg Hinderling
Replied On June 1, 2004 09:47 PM UTC

Getting and setting row heights is actually quite easy and will work for base and derived classesm no need to use reflection: Get: the rowheight of a grid row can always be determined from the GetCellBounds(row,col).Height property. Set: raise MouseDown and MouseUp events with MouseEventArgs set to same values as if one manually resized a column by clicking in the row resize area. Works perfectly.

Jurg Hinderling
Replied On June 1, 2004 09:59 PM UTC

Gee, I am talking to myself :-) of course the approach I described without using reflection works only for derived classes as OnMouseUp and OnMouseDown are protected DatatGrid methods. Sorry for the confusion.

Manish
Replied On June 11, 2004 01:03 PM UTC

I have the same porblem with the derived grid class. if your method does not require to use reflection and "get_DatagridRows" method. wonderful. Could you send me little code snippet. if you have. I did not quite understand the set : thing. thanks > Getting and setting row heights is actually quite easy and will work for base and derived classesm no need to use reflection: > > Get: the rowheight of a grid row can always be determined from the GetCellBounds(row,col).Height property. > > Set: raise MouseDown and MouseUp events with MouseEventArgs set to same values as if one manually resized a column by clicking in the row resize area. Works perfectly.

Manish
Replied On June 11, 2004 01:22 PM UTC

I have used following code in autoresize method instead of relfection, but it does not seem to work. Dim i As Integer While i < numRows 'get the current height of he pearicular cell. size = g.MeasureString(dgEdit(i, 1).ToString(), dgEdit.Font, 400, sf) Dim h As Integer = Convert.ToInt32(size.Height) h = h + 10 Dim cellRect As Rectangle cellRect = dgEdit.GetCellBounds(i, 1) cellRect.Height = h i += 1 End While thanks. any idea. Manish > I have the same porblem with the derived grid class. if your method does not require to use reflection and "get_DatagridRows" method. wonderful. > > Could you send me little code snippet. if you have. I did not quite understand the set : thing. > > thanks > > > > > Getting and setting row heights is actually quite easy and will work for base and derived classesm no need to use reflection: > > > > Get: the rowheight of a grid row can always be determined from the GetCellBounds(row,col).Height property. > > > > Set: raise MouseDown and MouseUp events with MouseEventArgs set to same values as if one manually resized a column by clicking in the row resize area. Works perfectly. >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;