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

Form as a control?

P: n/a
Hi,

Is there a way to have a form as a control? Here's what I want to do:

I have a datagrid which displays various information. However, I want to
use it in multiple locations within the same application. Instead of
creating an instance of the grid and linking up the same data on each form,
I want to have a "floating" form which contains my grid in my application.
When a new form needs this grid, I would, say, take the form (with the grid)
and add it to a panel as a child control ... does this work?

Is this even a good approach? Any examples?

Thanks in advance,

Chris

Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Chris wrote:
Hi,

Is there a way to have a form as a control? Here's what I want to do:

I have a datagrid which displays various information. However, I want to
use it in multiple locations within the same application. Instead of
creating an instance of the grid and linking up the same data on each form,
I want to have a "floating" form which contains my grid in my application.
When a new form needs this grid, I would, say, take the form (with the grid)
and add it to a panel as a child control ... does this work?

Is this even a good approach? Any examples?

Thanks in advance,

Chris


Instead of a form as a base for you grid, use a panel.
So you can create a control panel+grid on it. This way you can create PanelGrid control one time and
then place it on different forms/panels

Hope it helps,
Andrey aka MuZZy
Nov 16 '05 #2

P: n/a
"Chris" <ch***@no-spam.com> wrote in
news:#O**************@TK2MSFTNGP10.phx.gbl:
Is there a way to have a form as a control? Here's what I want to do:

I have a datagrid which displays various information. However, I want
to use it in multiple locations within the same application. Instead of
creating an instance of the grid and linking up the same data on each
form, I want to have a "floating" form which contains my grid in my
application. When a new form needs this grid, I would, say, take the
form (with the grid) and add it to a panel as a child control ... does
this work?


Make a panel with a grid, then make it a user control and you can then redrop
it on any form to reuse it.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 16 '05 #3

P: n/a
Elp
On Tue, 15 Feb 2005 09:24:42 -0800, Chris wrote:
I have a datagrid which displays various information. However, I want to
use it in multiple locations within the same application. Instead of
creating an instance of the grid and linking up the same data on each form,
I want to have a "floating" form which contains my grid in my application.
When a new form needs this grid, I would, say, take the form (with the grid)
and add it to a panel as a child control ... does this work?

Is this even a good approach? Any examples?


A form is a nothing more than a control (it derives from ContainerControl).
So you can use a form as you would use any other control and place it
within other container controls (such as Panels) if you wish. However, in
your case, i would suggest you to simply create a User Control (right click
on your project, add new item -> user control). Place your datagrid on this
control, add all the public methods you need and there you go. You can then
place this control wherever you want, move it from one place to another...
Nov 16 '05 #4

P: n/a
Chris,

I thought it was this one.
http://msdn.microsoft.com/library/de...leveltopic.asp

(And than setting to false)

I hope this helps,

Cor
Nov 16 '05 #5

P: n/a
Thanks for all your responses ... I'll give it a go ...
"Chris" <ch***@no-spam.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

Is there a way to have a form as a control? Here's what I want to do:

I have a datagrid which displays various information. However, I want to
use it in multiple locations within the same application. Instead of
creating an instance of the grid and linking up the same data on each form, I want to have a "floating" form which contains my grid in my application.
When a new form needs this grid, I would, say, take the form (with the grid) and add it to a panel as a child control ... does this work?

Is this even a good approach? Any examples?

Thanks in advance,

Chris

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.