|
well I've this trouble, I need to close all the windows in my app....
I'm using MDIForms.
To close some forms I use this code above:
foreach(Form frm in this.MdiChildren)//when this is my MDIParent
{
frm.Close();
}
seems simple but I need to close ShowDialog Forms (ShowDialog isn't a MDIChild), when one ShowDialogForm is open I can't to close it, It's still open, How do I'll to close it?
Thanks
|
|
|
|
|
Alex
I am still a newbie at C# also but I am developing a MDIApplication and I am using a Login form as a dialog. To close that form I have put a close button on the form and then used the code this.dispose(); as the way to close it.
private void button1_Click(object sender, EventArgs e)
{
this.dispose();
}
Hope this helps!
Allan
Allan F. Gagnon
|
|
|
|
|
You should use the Close method instead of Dispose to close your login form.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks Allan
But I can to close one window....
The problem is many windows.. I'm going to explain my app, when time expire I need to close all windows that are open, however, some of these windows are ShowDialog, when I execute the sample code above the only windows that are closed are the MDIChildren, however, ShowDialog windows not is MDIChild and therefore still open, I can't handle these.
I don't know who is owner of theses windows ShowDialog()
I'm tired..
|
|
|
|
|
Hi..
In my application i have a situation where for particular period of time
specific no.of threads are created in SmartThreadPool..
And its working fine..
Now i want to dequeue some of the Thread items from the ThreadPool,
to stop the Threads..
I'm not sure how to get this..
Please help me..
For pooling i'm using SmartThreadPool.
thanks,
nas
|
|
|
|
|
Hello,
I think you would have to call the Aport method of the thread instance.
All the best,
Martin
|
|
|
|
|
Hi,
In C# 2005 I need a hint how to solve if there is a control on a form and I click or select it in design-time, the Click event is fired in design-time. Important that in design-time! How can I catch the OnClick event or anything else in design-time? Also for Control or any ToolStripItem, like ToolStripButton.
Please help, it's important!
Thanks,
Attila
|
|
|
|
|
if ( this.DesignMode ) {
this.ProcessDesignTimeClick(e);
}
else{
this.ProcessRunTimeClick(e);
}
Geniality is in simplicity.
|
|
|
|
|
Thanks Jakub, but I do not really understand where to put this code, I do not have ProcessDesignTimeClick or ProcessRunTimeClick. How can I link it to a Button? Could you please more specific?
Thanks,
Attila
|
|
|
|
|
Class "System.ComponentModel.Component" has "Site" property typed as "ISite". The ISite interface has "DesignMode" property typed as "bool".
If value of "Site" property is not null, the component propably is in some designer. But if "Site.DesignMode == true", you can be sure.
So following method return true, if specified component is in designer:
bool IsInDesignMode(Component component) {
ISite site = component.Site;
bool ret = ( site != null && site.DesignMode );
return ret;
}
Class "System.Windows.Forms.Control" has "Site" property too and besides protected property "DesignMode" ( which's body is similar to 'IsInDesignMode' method ).
So, if you want to find out, if clicked button is in design mode, you check value of their "Site" property.
Example:
public class MyButton : Button {
protected override void OnClick( EventArgs e ){
if ( this.DesignMode ) {
MessageBox.Show( "This button is in design mode. Raising event 'Click' is verboten." );
}
else {
base.OnClick( e );
}
}
}
Or:
public class MyForm : Form {
private Button button1;
...
...
...
private void button1_Click(object sender, EventArgs e){
ISite site = this.button1.Site;
if ( site != null && site.DesignMode ){
MessageBox.Show("Button was clicked in design mode.");
}
else{
MessageBox.Show("Button was clicked in run-time mode.");
}
}
}
If you compose usercontrols in hierarchy, only the most top control in designer has value of "DesignMode" property set to "true".
You must search in hierarchy for real state of design mode.
Example:
<code>public class MyControl_A : UserControl{
private MyControl_B myCtl_B;
public MyControl_A(){
this.myCtl_B = new MyControl_B();
this.Controls.Add(this.myCtl_B);
}
}
public class MyControl_B : UserControl{
protected bool IsInDesignMode(){
bool ret = false;
Control ctl = this;
while( ctl != null && ret == false ){
ISite site = ctl.Site;
if ( site != null ){
ret = site.DesignMode;
}
ctl = ctl.Parent;
}
return ret;
}
protected override void OnClick(EventArgs e){
if ( this.IsInDesignMode() ){
MessageBox.Show("This control is in design mode.");
}
else{
base.OnClick(e);
}
}
}
Geniality is in simplicity.
|
|
|
|
|
An article that I have wrote here may be able to help you:Targeting Design-Time Events of User Controls[^].
You should be able to catch the click event in the WndProc of the designer of the control.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thanks Thomas, I have downloaded your code and tried it, but I thought there is a simplier way. It's too complicated.
Attila
|
|
|
|
|
I am sure their is a simpler way, but this is the only way that I can think of at this time.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi,
I want to make macro, which should find some types in assemblies, which are referenced in project. I found documentation for interface VSLangProject.Reference & VSLangProject.Reference2, but I did not found any way how get types of that assembly.
Only way I know, is load assembly with Assembly.LoadFrom(), and then search types with reflection. But I dont find out this way effective.
Anyony can help me?
Thanks.
Geniality is in simplicity.
|
|
|
|
|
Hi everyone, I hope this's not a programming question
Can anyone tell me what do you use in C# to map some parts of an image?? say, to link some event to that part just like in front page?? any tool/way to do that??
Thanks a bunch guys
-- modified at 10:02 Thursday 15th February, 2007
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Sounds like a programming question to me
Either handle the onclick of your image, and work out which bit has been clicked, or put some kind of transparent control over each part of your image, and handle the click on those instead.
|
|
|
|
|
benjymous wrote: work out which bit has been clicked
I guess that was the question
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
At risk of answring a programming question in the lounge, you'd typically break your image into rectangular areas ( conceptually, or physically ), and track which rectangle had been clicked in.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thank you Chris, though, I really didn't feel like it's a programming question, and I'm sorry it was turned to be one.. I just thought somebody would point out a tool for me and since I know the lounge is very active and since this's a part of a programming forum, even people in the lounge can give us tips or point out some useful tools out of their experience.
I apologize again and thank you for those who tried to help.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
How can i find the length of the text in textbox in the pixel (n pixel )
With thanks
MHF
|
|
|
|
|
|
|
Hi everyone,
Does anyone know if there's a good way to map parts of an image just like how we used to do in front page??
Thanks a bunch
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
What is the code to get the current bandwith speed?
|
|
|
|
|
Use a performance counter control.
Set the following properties:
CategoryName = Network Interface
CounterName = Current Bandwidth
InstanceName = name of the network adapter you want the bandwidth from
Hope this was helpful.
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|