473,799 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New Form Class With DataGridView

Hello together,

I have a main form which includes a Datatoolstripme nu. 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 sUBNRChasingToo lStripMenuItem_ Click(object sender,
EventArgs e)
{
Form3 chForm1 = new Form3();
chForm1.MdiPare nt = this;
chForm1.Show();
}

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

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

private void Form3_Load(obje ct sender, EventArgs e)
{
this.vTableAdap ter.Fill(this.d ataset.view);
}
Thanks in advance for help.

Kind regards.

Dec 19 '07 #1
1 1778
On Wed, 19 Dec 2007 06:53:14 -0800, SePp <C_*******@gmx. dewrote:
Hello together,

I have a main form which includes a Datatoolstripme nu. 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
1011
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 that I can't access the properties of in my child forms. For example I create a form called BrowseForm1 in a different project that inherits from ODBrowseForm. When viewing BrowseForm1 in the visual designer I can't move or resize the...
0
3280
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 use all the controls and nothing happens, I can't even exit the application!!! Any idea? The DataSource of this DataGridView is a class that extends the System.ComponentModel.BindingList.
6
3499
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, minimizes the MDI form. Why is this happening and how can I prevent it? Important thing to say is, if I use just "OK" MessageBox, it DOES NOT minimize the MDI parent. TIA Goran
1
5067
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 form display the data using a data grid view and the add record form creates an object and passes that data to a class method which creates the record using sqlcommand. The add new record form is loaded after the user clicks on the add button on...
5
5487
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 instance. I currently have the form where it will open from a double click on datagridview from another form to the proper record and only one instance. However, doing this bypassed by databinding source for opening the form to all records. I still...
11
76286
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 else who got stumped like I did. It seems so simple... binding a DataGridView to a List<T>. These are the two general problems that I kept running into: (1) When the data in the list updated, the data on the screen did not update. (2) When I...
1
2846
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 controls are locked on this form. I have another windows form call "ChildForm" that inherits "BaseForm". When I open"BaseForm: in VS2005 I can see both the DataGridView and the button and I can view all of the properties of these controls. ...
5
4070
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
10645
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 to a DataTable, and then loop through the rows setting the background colour of the last cell to LightGrey and the cell itself to read-only if the column value is true. After the form finishes loading the code didn't work i.e. the cells are not set...
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.