•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 391,913 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,718 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser:
Views: 4318 | Replies: 11
![]() |
•
•
Join Date: Jul 2007
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
Hi 
I have a caple of questions:
1) How can i create a global function or a global class
that will be available to the entire project ?
2) I want to create derived class from the DataGridView class
and change it so it will fit to my needs, and after that i want
that this new dataGridView will be available in the ToolBox.
How can i do that ?
3) I want that the Minimize button of the ControlBox in a form
will do more things besides Minimizing the specific form, how
can i change what this button does ?
Thanks.

I have a caple of questions:
1) How can i create a global function or a global class
that will be available to the entire project ?
2) I want to create derived class from the DataGridView class
and change it so it will fit to my needs, and after that i want
that this new dataGridView will be available in the ToolBox.
How can i do that ?
3) I want that the Minimize button of the ControlBox in a form
will do more things besides Minimizing the specific form, how
can i change what this button does ?
Thanks.
•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation:
Rep Power: 7
Solved Threads: 58
1 is easy
right click website or project, 'Add New Item'
Add a class file
add a public static method eg;
myGlobalClass.cs
Call it in your code:
2. Derived DataGrid
Create a separate class library project, add a class file myDataGrid.cs
Look up ToolboxBitMap, ToolboxData and Designer attributes to customise the icon for the toolbox, what is written to the aspx page when you drag your control into the designer and how it looks in the designer.
Build your class library, In your toolbox right click and choose items and browse to the dll you just built, select the control from the list.
3. I don't really understand what you mean with this one sorry.
What you're asking for is too much to explain properly in a single post in a forum, you need to get yourself a good book on the subject, there are hundreds. These forums are really for when you already have made your derived class, function or whatever and you need help tweaking it or getting it to work.
right click website or project, 'Add New Item'
Add a class file
add a public static method eg;
myGlobalClass.cs
public class myGlobalClass
{
public static void myGlobalFunction()
{
//function logic ...
}
}Call it in your code:
myGlobalClass.myGlobalFunction();
2. Derived DataGrid
Create a separate class library project, add a class file myDataGrid.cs
public class myDataGrid : DataGrid
{
//add your override members and methods here
}Look up ToolboxBitMap, ToolboxData and Designer attributes to customise the icon for the toolbox, what is written to the aspx page when you drag your control into the designer and how it looks in the designer.
Build your class library, In your toolbox right click and choose items and browse to the dll you just built, select the control from the list.
3. I don't really understand what you mean with this one sorry.
What you're asking for is too much to explain properly in a single post in a forum, you need to get yourself a good book on the subject, there are hundreds. These forums are really for when you already have made your derived class, function or whatever and you need help tweaking it or getting it to work.
Last edited by hollystyles : Aug 2nd, 2007 at 7:59 am.
•
•
•
•
3) I want that the Minimize button of the ControlBox in a form
will do more things besides Minimizing the specific form, how
can i change what this button does ?
The truth does not change according to our ability to stomach it.
•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation:
Rep Power: 7
Solved Threads: 58
•
•
•
•
You can't change that behavior. You have to remove it completely by setting the FormBorderStyle to None and make your own from scratch.
the OP doesn't want to change the behaviour, he want's to add additional behaviour.
Check out the Form.Resize event, hook that event and add your
logic. You need to check the WindowState:
private void Form1_Resize(object sender, System.EventArgs e)
{
//Check to see if the window has been Minimized:
if (this.WindowState == FormWindowState.Minimized)
{
//do stuff...
}
}•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation:
Rep Power: 7
Solved Threads: 58
Ok so you agree it can be changed now then, that's cool
•
•
Join Date: Nov 2006
Location: Bonners Ferry, ID
Posts: 279
Reputation:
Rep Power: 2
Solved Threads: 38
#3, you can't stop it from sending the a minimize command (without some Windows API calls), however if you want it to do more things before it minimizes, you can use the Deactivated Event handler or the SizeChanged event (http://www.thescripts.com/forum/thread275452.html). If you want to stop the minimize action, then you have to trap the message and do what you want... this calls for importing some WinAPI stuff, which like hollystyles said, is too much to go into this thread.
You also might want to look into a Notify component to trap the minimize event.
You also might want to look into a Notify component to trap the minimize event.
•
•
Join Date: Jul 2007
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
Hi 
Thanks for all the answers.
I have a problem:
I tryed to do what Hollystyles sayd (question number 2)
But i couldnt use the DataGridView class as a base class.
How can i do it ?
Here is the code in the Class Library Project:
The error line:
I tryed to add some Usings but it didnt helped,
what are the Usings that i need to add ?
What is the problem ?
Thanks.

Thanks for all the answers.
I have a problem:
I tryed to do what Hollystyles sayd (question number 2)
But i couldnt use the DataGridView class as a base class.
How can i do it ?
Here is the code in the Class Library Project:
using System;
using System.Collections.Generic;
using System.Text;
namespace DataGridViewComponent
{
public class DataGridView2: DataGridView
{
}
}The error line:
•
•
•
•
Error 1: The type or namespace name 'DataGridView' could not be found (are you missing a using directive or an assembly reference?)
I tryed to add some Usings but it didnt helped,
what are the Usings that i need to add ?
What is the problem ?
Thanks.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
Similar Threads
- global or function? (Python)
- Multithreading error (C++)
Other Threads in the C# Forum
- Previous Thread: fixing the column size of a datagrid
- Next Thread: some doubts



Linear Mode