G
Guest
I have a Windows Forms-based project in Visual Studio 2005, containing a
simple user control (class) and a form (class) that hosts an instance of the
user control.
The user control class contains (aggregates) a DataGridView instance (using
a private modifier). Also, within the user control class, I have a public
property that allows external entities (such as the main form) to access the
inner DataGridView instance like this:
public DataGridView InnerDataGridView
{
get { return this.innerDataGridView; }
}
I compile the project, then open the main form in design mode. It displays
the form that contains the user control instance, that contains the
DataGridView instance. In the Properties window, when I select the user
control instance in the form, I have all user control's public properties, as
expected, including the InnerDataGridView property which has a plus (+/-)
sign in front, allowing me to expand it to read or set properties of the
inner DataGridView instance.
Everything seems right until I try to click the ellipsis button (...) on the
Columns property of the inner DataGridView. This means, in the form I have
selected the user control instance, and in the Properties window I expanded
InnerDataGridView property, selected the Columns [sub-]property, and clicked
on the ellipsis button in the right side.
At this time, Visual Studio designer displays a "object reference not set to
an instance of an object" error in a simple modal message box, and offers no
other details, and this seems to happen within DataGridView (i.e. not in my
code), or I run into a architectural/design restriction which I wasn't aware
of.
(I tried also to create an InnerColumns property in the user control class
that maps to the InnerDataGridView.Columns to have the InnerColumns property
directly in the list of properties of the user control, but even if this way
I didn't receive the message box, and the grid columns editor/designer modal
dialog was open, it wouldn't allow me to create new columns - i.e. when
adding a new column it said that "at least one column doesn't have a
template" and didn't save the column. However, if possible, I don't want to
go through such workarounds for my issue, I think there should be a way to
make the first method work, without the InnerColumns property.)
Does anybody knows more about this issue - why does it happen, and more
important, how can I get over it? I want the end user of my user control
(which will be delivered in a library not in a form in the end) to be able to
set up columns in the inner grid by using the standard columns designer.
Thank you very much in advance,
simple user control (class) and a form (class) that hosts an instance of the
user control.
The user control class contains (aggregates) a DataGridView instance (using
a private modifier). Also, within the user control class, I have a public
property that allows external entities (such as the main form) to access the
inner DataGridView instance like this:
public DataGridView InnerDataGridView
{
get { return this.innerDataGridView; }
}
I compile the project, then open the main form in design mode. It displays
the form that contains the user control instance, that contains the
DataGridView instance. In the Properties window, when I select the user
control instance in the form, I have all user control's public properties, as
expected, including the InnerDataGridView property which has a plus (+/-)
sign in front, allowing me to expand it to read or set properties of the
inner DataGridView instance.
Everything seems right until I try to click the ellipsis button (...) on the
Columns property of the inner DataGridView. This means, in the form I have
selected the user control instance, and in the Properties window I expanded
InnerDataGridView property, selected the Columns [sub-]property, and clicked
on the ellipsis button in the right side.
At this time, Visual Studio designer displays a "object reference not set to
an instance of an object" error in a simple modal message box, and offers no
other details, and this seems to happen within DataGridView (i.e. not in my
code), or I run into a architectural/design restriction which I wasn't aware
of.
(I tried also to create an InnerColumns property in the user control class
that maps to the InnerDataGridView.Columns to have the InnerColumns property
directly in the list of properties of the user control, but even if this way
I didn't receive the message box, and the grid columns editor/designer modal
dialog was open, it wouldn't allow me to create new columns - i.e. when
adding a new column it said that "at least one column doesn't have a
template" and didn't save the column. However, if possible, I don't want to
go through such workarounds for my issue, I think there should be a way to
make the first method work, without the InnerColumns property.)
Does anybody knows more about this issue - why does it happen, and more
important, how can I get over it? I want the end user of my user control
(which will be delivered in a library not in a form in the end) to be able to
set up columns in the inner grid by using the standard columns designer.
Thank you very much in advance,