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

New Form Class With DataGridView

P: n/a
Hello together,

I have a main form which includes a Datatoolstripmenu. From one of
these items I want to call
a Form which includes an DataGridview. I want to use this form and
datagridview as template and call It a lot of time from diffrent menu
items.( But with diffrent data (views))

What is the best way to do that. My problem is to find a way to say:
If this menu item is clicked load the template form with the template
gridview but with a special dataset(view). (The Dataset include
diffrent views)

Main Form/Menu:

private void sUBNRChasingToolStripMenuItem_Click(object sender,
EventArgs e)
{
Form3 chForm1 = new Form3();
chForm1.MdiParent = this;
chForm1.Show();
}

and this is the form I want to use as template;

public partial class Form3 : Form
{
public Form3(String LoadGrid)
{
InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)
{
this.vTableAdapter.Fill(this.dataset.view);
}
Thanks in advance for help.

Kind regards.

Dec 19 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 19 Dec 2007 06:53:14 -0800, SePp <C_*******@gmx.dewrote:
Hello together,

I have a main form which includes a Datatoolstripmenu. From one of
these items I want to call
a Form which includes an DataGridview. I want to use this form and
datagridview as template and call It a lot of time from diffrent menu
items.( But with diffrent data (views))

What is the best way to do that. My problem is to find a way to say:
If this menu item is clicked load the template form with the template
gridview but with a special dataset(view). (The Dataset include
diffrent views)
Well, you're already passing a string to the form's constructor (but your
sample code using it doesn't use that constructor?). Why not just pass
the view you want to the constructor as well? Alternatively, create a
property for the form class that you can set after constructing the form
but before showing it.

If you want the form to use a specific view given the context, you have to
pass that view to the form class somewhere. The constructor or a property
are the most common ways of doing that. Of course, you could also just
make a method in the class that you can call to set the view. In all
cases, you'll either set the view directly (calling Fill() as in your
example code) or assign the view to an instance variable that is used
later when calling Fill(). What's most appropriate will depend on the
exact design of your form code.

Pete
Dec 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.