By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

Help with referencing base class

P: n/a
I built a windows control which inherits from the windows datagrid

Public Class XDataGrid
Inherits System.Windows.Forms.DataGrid
Private _AutoSizeDataGrid As Boolean
Private _AutosizeColumns As Boolean
I have found some code which can be used to autosize the columns in a
windows datagrid. This works fine if you put the code in a form.
However I want to put the code in my custom control (xdatagrid) and
have it work on my base (inherited) datagrid class.

Here is the code

1 Dim t As Type = MyBase.GetType

2 Dim m As Reflection.MethodInfo = t.GetMethod("ColAutoResize",
Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)

3 Dim i As Integer = MyBase.FirstVisibleColumn
4 Dim j As Integer = MyBase.VisibleColumnCount
6 Do While i < j
7 m.Invoke(MyBase, New Object() {i})
8 i = i + 1
9 Loop

The problem is that line 7 expects to invoke the method on a datagrid
object. However, I cannot get a reference to the underlying datagrid
object that my xDatagrid inherits from.

Me will reference my xdatagrid object which doesn't work
Mybase will work for lines 1,2,3 and 4 but m.Invoke won't except
Mybase as a parameter.

Anyone out there who can make this work?


Nov 8 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.