473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid - Setting Row Height in Derived DataGrids

I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridro ws" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!

--
Dennis in Houston
Nov 21 '05 #1
5 4731
Hi,

I converted the grid in the article dragging and dropping datagrid
columns to vb.net. Noticed get_Datagridsro ws method doesnt work until the
grid had drawn itself.
Ken
-----------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridro ws" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!

--
Dennis in Houston
Nov 21 '05 #2
Your code works find if you have just a datagrid. However, when you have a
class that inherits datagrid, mi is returned as nothing. I even tried using
mybase.GetType instead of me.GetType inside of the class.

"Ken Tucker [MVP]" wrote:
Hi,

I converted the grid in the article dragging and dropping datagrid
columns to vb.net. Noticed get_Datagridsro ws method doesnt work until the
grid had drawn itself.
Ken
-----------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridro ws" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!

--
Dennis in Houston

Nov 21 '05 #3
Thanks to "Imran Koradia" :

Here's code that works to get and set rowheights in derived DataGrids. Note
the function to get the rowobjects and get/set property is all within the
derived DataGrid Class called mydatagrid. The RowObject array of rows is
updated by calling get_RowObjects whenever the datasource changes or a row is
changed with the mouse:

Public Class mydatagrid
Private RowObjects as Arraylist = new Arraylist

'Call this whenever datasource changes or row height changed by mouse
Private Function get_RowObjects( ) As ArrayList
Dim rows As ArrayList = New ArrayList
Dim a As Type = Me.GetType
Dim b As Type = a.BaseType
Dim mi As MethodInfo = b.GetMethod("ge t_DataGridRows" ,
BindingFlags.Fl attenHierarchy Or BindingFlags.Ig noreCase Or
BindingFlags.In stance Or BindingFlags.No nPublic Or BindingFlags.Pu blic Or
BindingFlags.St atic)
Dim dgra As System.Array = CType(mi.Invoke (Me, Nothing), System.Array)
Dim dgrr As Object
For Each dgrr In dgra
If dgrr.ToString() .EndsWith("Data GridRelationshi pRow") = True Then
rows.Add(dgrr)
End If
Next dgrr
Return rows
End Function 'get_RowHeights

'Use this Property to set or get rowheights
Public Property RowHeight(ByVal row As Integer) As Integer
Get
Try
Dim pi As PropertyInfo =
rowObjects(row) .GetType().GetP roperty("Height ")
Return CInt(Fix(pi.Get Value(rowObject s(row), Nothing)))
Catch
Throw New ArgumentExcepti on("invalid row index")
End Try
End Get
Set(ByVal Value As Integer)
Try
Dim pi As PropertyInfo =
rowObjects(row) .GetType().GetP roperty("Height ")
pi.SetValue(row Objects(row), Value, Nothing)
Catch
Throw New ArgumentExcepti on("invalid row index")
End Try
End Set
End Property

Thanks a lot for helping me.

"Ken Tucker [MVP]" wrote:
Hi,

I converted the grid in the article dragging and dropping datagrid
columns to vb.net. Noticed get_Datagridsro ws method doesnt work until the
grid had drawn itself.
Ken
-----------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridro ws" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!

--
Dennis in Houston

Nov 21 '05 #4
Actually - anyone have any idea how I can get the vertical scrolling
for this working correctly?

I'm actually using a wrapped-text derived Column, followed by the
syncfusion method for setting rowheights automatically. However, the
vertical scrollbar doesn't appear corrently (if the wrap-text column
is 2 lines, then you need to add an additional line into the datatable
before the vert scrollbar appears, and then it will let you scroll
down (and not be able to view the last record)

It appears that the scrollbar doesn't take account of
larger-than-normal rowheights, if they're set by reflection.

Argh!

B.

Dennis <De****@discuss ions.microsoft. com> wrote in message news:<37******* *************** ************@mi crosoft.com>...
Thanks to "Imran Koradia" :

Here's code that works to get and set rowheights in derived DataGrids. Note
the function to get the rowobjects and get/set property is all within the
derived DataGrid Class called mydatagrid. The RowObject array of rows is
updated by calling get_RowObjects whenever the datasource changes or a row is
changed with the mouse:

Public Class mydatagrid
Private RowObjects as Arraylist = new Arraylist

'Call this whenever datasource changes or row height changed by mouse
Private Function get_RowObjects( ) As ArrayList
Dim rows As ArrayList = New ArrayList
Dim a As Type = Me.GetType
Dim b As Type = a.BaseType
Dim mi As MethodInfo = b.GetMethod("ge t_DataGridRows" ,
BindingFlags.Fl attenHierarchy Or BindingFlags.Ig noreCase Or
BindingFlags.In stance Or BindingFlags.No nPublic Or BindingFlags.Pu blic Or
BindingFlags.St atic)
Dim dgra As System.Array = CType(mi.Invoke (Me, Nothing), System.Array)
Dim dgrr As Object
For Each dgrr In dgra
If dgrr.ToString() .EndsWith("Data GridRelationshi pRow") = True Then
rows.Add(dgrr)
End If
Next dgrr
Return rows
End Function 'get_RowHeights

'Use this Property to set or get rowheights
Public Property RowHeight(ByVal row As Integer) As Integer
Get
Try
Dim pi As PropertyInfo =
rowObjects(row) .GetType().GetP roperty("Height ")
Return CInt(Fix(pi.Get Value(rowObject s(row), Nothing)))
Catch
Throw New ArgumentExcepti on("invalid row index")
End Try
End Get
Set(ByVal Value As Integer)
Try
Dim pi As PropertyInfo =
rowObjects(row) .GetType().GetP roperty("Height ")
pi.SetValue(row Objects(row), Value, Nothing)
Catch
Throw New ArgumentExcepti on("invalid row index")
End Try
End Set
End Property

Thanks a lot for helping me.

"Ken Tucker [MVP]" wrote:
Hi,

I converted the grid in the article dragging and dropping datagrid
columns to vb.net. Noticed get_Datagridsro ws method doesnt work until the
grid had drawn itself.
Ken
-----------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridro ws" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!

--
Dennis in Houston

Nov 21 '05 #5
I share your thoughts regarding the Microsoft DataGrid..ARGH! It is really
not suited for much customization although they claim it is. I have even had
trouble getting it to show data in the column when a column is scrolled back
on to the screen. Also, it doesn't sort bound arraylists. I've given up on
it and am currently working on my own...I don't like paying 200 to 300 bucks
for a third party control.

You'd think Microsoft could produce a better control.

"Barry Zubel" wrote:
Actually - anyone have any idea how I can get the vertical scrolling
for this working correctly?

I'm actually using a wrapped-text derived Column, followed by the
syncfusion method for setting rowheights automatically. However, the
vertical scrollbar doesn't appear corrently (if the wrap-text column
is 2 lines, then you need to add an additional line into the datatable
before the vert scrollbar appears, and then it will let you scroll
down (and not be able to view the last record)

It appears that the scrollbar doesn't take account of
larger-than-normal rowheights, if they're set by reflection.

Argh!

B.

Dennis <De****@discuss ions.microsoft. com> wrote in message news:<37******* *************** ************@mi crosoft.com>...
Thanks to "Imran Koradia" :

Here's code that works to get and set rowheights in derived DataGrids. Note
the function to get the rowobjects and get/set property is all within the
derived DataGrid Class called mydatagrid. The RowObject array of rows is
updated by calling get_RowObjects whenever the datasource changes or a row is
changed with the mouse:

Public Class mydatagrid
Private RowObjects as Arraylist = new Arraylist

'Call this whenever datasource changes or row height changed by mouse
Private Function get_RowObjects( ) As ArrayList
Dim rows As ArrayList = New ArrayList
Dim a As Type = Me.GetType
Dim b As Type = a.BaseType
Dim mi As MethodInfo = b.GetMethod("ge t_DataGridRows" ,
BindingFlags.Fl attenHierarchy Or BindingFlags.Ig noreCase Or
BindingFlags.In stance Or BindingFlags.No nPublic Or BindingFlags.Pu blic Or
BindingFlags.St atic)
Dim dgra As System.Array = CType(mi.Invoke (Me, Nothing), System.Array)
Dim dgrr As Object
For Each dgrr In dgra
If dgrr.ToString() .EndsWith("Data GridRelationshi pRow") = True Then
rows.Add(dgrr)
End If
Next dgrr
Return rows
End Function 'get_RowHeights

'Use this Property to set or get rowheights
Public Property RowHeight(ByVal row As Integer) As Integer
Get
Try
Dim pi As PropertyInfo =
rowObjects(row) .GetType().GetP roperty("Height ")
Return CInt(Fix(pi.Get Value(rowObject s(row), Nothing)))
Catch
Throw New ArgumentExcepti on("invalid row index")
End Try
End Get
Set(ByVal Value As Integer)
Try
Dim pi As PropertyInfo =
rowObjects(row) .GetType().GetP roperty("Height ")
pi.SetValue(row Objects(row), Value, Nothing)
Catch
Throw New ArgumentExcepti on("invalid row index")
End Try
End Set
End Property

Thanks a lot for helping me.

"Ken Tucker [MVP]" wrote:
Hi,

I converted the grid in the article dragging and dropping datagrid
columns to vb.net. Noticed get_Datagridsro ws method doesnt work until the
grid had drawn itself.
Ken
-----------------
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
I have a class that inherits from DataGrid. I can set the rowheights in a
DataGrid by tappig into the "get_Datagridro ws" method. However, this does
not work for classes that inherit from DataGrid. Anyone know how to do this
on derived classes? I find it apalling that Microsoft provided a DataGrid
that is so inflexible!

--
Dennis in Houston

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7800
by: Stephan Steiner | last post by:
Hi I'm using several DataTables in my program which are updated periodically. At the same I have those tables bound to DataGrids in my GUI. So far I've been doing all the processing in the same program and the speed of the processing prevented any issues when it comes to updating the GUI elements (as DataTables are changed this triggers...
3
6814
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article: http://msdn.microsoft.com/msdnmag/issues/03/08/DataGrids/default.aspx I have a problem when there are two DataGrid's on one form, and when I switch focus from one grid to the other. To be more...
5
2363
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes, check boxes, date pickers, combo boxes and datagrids). I have been coding alone on this project for about a year, and I have experienced many...
2
423
by: Sebastian | last post by:
Hi, I have datagrid. In its footer there is editbox to add new item. All is cool. Datagrids 'Delete' button has CausesValidation set to false and all is great. But the problem is in 'Process' page button. ('Process' button saves all data on the page to database). When I click 'Process' button datagrids footer textbox are being validated...
5
1869
by: Kat | last post by:
Hi, I'm trying to set up an asp.net page using flow layout so I'm putting all my controls into a table grid, etc. I use several radiobuttonlists and datagrids that are generated from datasource. The radiobuttonlists are fine, they size depending on how many item are called into it. However, the datagrids, prior to filling with data contain...
9
5041
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ******************************************************************************* <asp:DataGrid visible="False" border=1
13
2459
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for them. In a plain vanilla DataGrid, when you click on the RowHeader, the appropriate row changes colors. I ASSUME this should be done in the Paint...
2
1685
by: Brian Tkatch | last post by:
This is mostly for the fun of it. Just saw it in the FAQ and figured i'd quickly give it a shot. The syncfusion FAQ <URL:http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q480q> mentions: "5.9 How can I put a combobox in a column of a datagrid? There are several ways to go about this task. The simplest way involves
2
3431
by: Mike Baugh | last post by:
I am using visual studio 2005 to develop a form using c# I have 3 datagrids on one form. I can set the row color based on a certain value in a column. However this color applies to all 3 datagrida. I would like to set it so that if value of column 3 in datagrid 1 is < 100 set to red, if = 100 set to green if value of column 3 in...
0
7620
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7931
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7684
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7985
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1230
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
959
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.