Form Closing event - c#

I have a smartdevice project targeting windows mobile 6.
In the top right corner is an X (provided by the controlbox). i have an event on the form_closing that i was hoping would fire when the cross is clicked. But it doesnt :-(
Does anyone know why this event is not firing ???
Thanks :-)
John

Set the MinimizeBox property of your form to false. It's a weird thing about WinMo forms, but the X in the corner is really a minimize button, so it doesn't actually close the form. Setting MinimizeBox to false will replace the X with an OK button, and you'll get the form closing event.

Read this: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.closing.aspx

There are a number of possible reasons why theis could be happening, but I seriously doubt anyone will be able to guess why in this case, without you letting us see any of your code?

Related

Why is all of the text on my window blank?

Sorry for asking such a basic question, but I just can't figure it out. I'm trying to display a status window that just says "Uninstalling prior versions" while the program runs so the user has some idea what's going on. So I created a C# form, added a label and do a window.show(). Here's what the form looks like in design mode:
And yet here's what displays:
I added a second label and a button to make sure that the text of my label wasn't some odd color or something that was causing the problem and they don't appear either.
What's going on here? This should be so simple. I've done this hundreds of times and never seen this behavior.
TaW said in this comment:
You can call Refresh() before starting the long-running work.
Refresh() was just what I needed!

WPF messagebox localization

Is there a way to change the Messagebox yes and no buttons text to something else ?
for example - Sí and No ?!
You can always make your own MessageBox. Just create a window with buttons and customize it the way you want to. Worked for me.
Try setting xml:lang='your languagecode' in the window where you call the messagebox from. Maybe that will work.
Edit: Google first hit: MessageBox buttons - set language?

textbox_tapped event not firing in metro app

I am building a win 8 app which has a textbox control inside a hierarchy of elements like ScrollViewer->Stackpanel->Grid->Image & TextBox. The textBox contain a tapped event to navigate to a page. This textbox_tapped event is not at all firing. I am not getting any error or exceptions also. Can somebody tell me the solution for getting this? Thank you.
Maybe something to do with the fact that you are testing it on a normal PC with a mouse, so its not a tap, though I'm not sure about that. You might get a similar result by using the "GotFocus" event instead.

MessageBox doesn't show on mdi form after a long calculation

This is a very similar problem to This one, sadly that one was never answered either.
I have a MDI Main forum that hosts several children forms. One of them does a long calculation and throws an exception if an error occurs (all work is done on the same thread). I then try to inform the user of an error with an messagebox, however it doesn't appear (but steals focus from the MDI Main, so the application is completely unresponsive).
The beheviour changes slightly if I call Application.DoEvents() (evil I know, but this is a last resort thing). Then the forms remain completely active and the messagebox only appears after I change active application (Alt+Tab) to something else and then back again.
What can I do to make sure the messagebox will be visible? I have already tried passing both, active child and MDI Main as parameter to the MessageBox.Show method. It doesn't change the behaviour.
To clarify: the messagebox is a part of the child form, however at this point I am willing to show it in any way that doesn't break the application. The messagebox should be modal, but it should be visible so it can be acknowledged by the user.
I had the same issue. When pressed ALT the popup showed.
It turned out to be a LinkedLabel that had the AutoSize property to true. The LinkedLabel was inside a FlowLayoutPanel. When I set the LinkedLabel.Text property to String.Empty. The LinkedLabel constantly tried to resize, which was causing the GUI to be constantly busy.
When I turned off the AutoSize property and the GUI no longer had to recalculate the positions. The GUI was no free. And the popup showed.
There could be other controls that are behaving the same.
See also:
https://connect.microsoft.com/VisualStudio/feedback/details/116884
Is the MessageBox shown in the MainForm or as part of the ChildForms? If the MessageBox is in the child Forms maybe you could pass an event back to the MainForm and open the MessageBox there.
The problem is that messageboxes tend to be modal.
In this instance I think that you'd do far better to use a delegate or an event with a handler in your main MDI code. That way your main application displays the message boxes. You can easily redefined an EventArgsType if you wish to pass whatever information that you require.

How to set NotifyIcon behavior to AlwaysShow in C#?

Is it possible to modify NotifyIcon behavior to AlwaysShow in C#? A code snippet would be greatly appreciated:) Thanks in advance...
Cheers
---edited
One of our clients said quote "it seems necessary to customise icons to always show". What he meant was that he has to do it manually by r-clicking on task bar then click on Properties -> Task Bar -> Customize Notifications and then you can set behavior to Always Show / Always Hide / Hide when inactive for each taskbar icon on the list.
Can you do that programically in C#?
I want to ensure that my NotifyIcon is ALWAYS visible. I'm already setting icon.Visible = true but it looks like it doesn't work for him hence the complaint.
Is there any easy way of setting the behavior by altering [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify] IconsStream registry value?
NotifyIcon icon = ...;
icon.Visible = true;
Edit for updated information: There shouldn't be, and if for some reason it exists, don't use it. That's the user's preference, not yours.
I'm sure it's possible with enough Registry hacking, but not at all recommended. They added the collapsing-notification-area behavior in XP because so many applications were shoving themselves in that space. Much like Start Menu pinning behavior in XP/Vista/7, the lack of a public API means you're supposed to let the user decide that sort of thing.

Categories

Resources