Help with Windows Control Library (DataGrid)...


C

Carl Fenley

I believe I have almost successfully created a custom datagrid control. The
new class builds without error. I have added it as reference to the main
Windows Application project. It appears on the Toolbox as expected, but...

When I drag-drop it on a Form, it appears like a component (e.g.
SqlConnection) down in it's own area not drawn on the form.

When I created the Windows Control Library, I never actually added a
DataGrid control to the Designer area, so there don't appear to be any GUI
objects in my custom DataGrid. Could this be my problem?

If so, in addition to dropping a DataGrid control onto the Designer area in
my Control Library, how will this change the code-behind that I've already
written?

Any help is greatly appreciated.

- carl
 
Ad

Advertisements

M

Mohamoss

Hi carl
This is not normal . when you create a windows control library , a UI
element is created by default for you . even if you didn't use it at all
there will be something that is dragged to the form area when you use this
control in a normal windows application . So , make sure that your datagrid
in implemented as windows control library , does it inherit
System.Windows.Forms.UserControl?

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
V

Vagabond Software

Mohamoss said:
Hi carl
This is not normal . when you create a windows control library , a UI
element is created by default for you . even if you didn't use it at all
there will be something that is dragged to the form area when you use this
control in a normal windows application . So , make sure that your datagrid
in implemented as windows control library , does it inherit
System.Windows.Forms.UserControl?
No. My custom datagrid inherits from System.Windows.Data.DataGrid. Here is the code snippet:

[ToolboxBitmap(typeof(DataGrid))]
public class CymiGrid : System.Windows.Forms.DataGrid

There are no references to UserControl (or UserControl1) anywhere in my code, and the following message is displayed when I switch to designer mode:

"To add components to your class drag them from Server Explorer or Toolbox and use the Properties window to set their properties. To create methods and events for your class, click here to switch to code view."

If I click anywhere on the blank (except for message) designer space, the Properties for my custom datagrid are displayed.

Thanks for any help or advice.

- carl
 
M

Mohamoss

Hi
Since it inherits System.Windows.Forms.DataGrid and it was implemented as a
windows control library then it should also display the normal datagird (
even if you did no modification on the interface ) . to double check I just
created one myself and it displayed correctly. There must be some other
issue within your solution we just didn't see yet. Does it created
container in the initialize component of the class. Do you see this line of
code in it
components = new System.ComponentModel.Container();

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
Ad

Advertisements

V

Vagabond Software

Mohamoss said:
Hi
Since it inherits System.Windows.Forms.DataGrid and it was implemented as a
windows control library then it should also display the normal datagird (
even if you did no modification on the interface ) . to double check I just
created one myself and it displayed correctly. There must be some other
issue within your solution we just didn't see yet. Does it created
container in the initialize component of the class. Do you see this line of
code in it
components = new System.ComponentModel.Container();
Ok, I think there may have been some kind of conflict or alteration between Visual Studio .NET 2003 and SharpDevelop. I use VS.NET at home, but I only have access to SharpDevelop at the client's location. So, I just copy the code files back and forth.

Anyway, I have created a new Windows Control Library project in VS.NET, copied the code over to the new project, and added the new build to the Toolbox. Everything now seems to be working as expected.

Thanks for you help.

- carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top