473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

New Form Class With DataGridView

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
1 1755
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Metal2You | last post by:
I have a base class form called ODBrowseForm that I've created which inherits from System.Windows.Forms.Form with no problems. The problem is that I have a DataGridView control in ODBrowseForm...
0
by: cris.b | last post by:
Hi, I have a problem with a DataGridView that has a readonly column of type "bool" When i click on a cell of that column the value doesn't change (OK) but after, all the form seems frozen! I can...
6
by: Goran Djuranovic | last post by:
Hi all, I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
1
by: romerve | last post by:
Hello; i am having some problems trying to get a form that has a datagridview to refresh after a new record is created. I have a MDI container and menu form and add new record form; the menu...
5
by: BD | last post by:
I am coding with C# in Visual Studio 2005 for a database application residing on remote MS SQL Server 2005. What I want to do is open the same form but from 2 different places and only one...
11
by: dave18 | last post by:
Hello all! I found a solution to my original question, but there's still so much I don't understand about it, I thought I'd give this forum a try. At the very least, maybe it will help someone...
1
by: mtembene | last post by:
I have a windows form "BaseForm" that contains a DataGridView that is not bound to any datasources and a button. Both of these controls have a modifier of "Protected Internal" and none of the...
5
by: Andrus | last post by:
Steps to reproduce issue: 1. Run code. 2. Enter some data to grid 3. Click other form caption 4. Click original form caption 5. Enter some characters Observed: entered characters are ignored
6
by: Ciaran | last post by:
I'm having a really strange issue with the DataGridView control in a VS2008 / .NET 3.5 winforms project. I have a simple form with a grid. In the form constructor I call a function to bind the grind...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.