I'm developing program perform multiple tasks in the loop, use 3rd party libraries. But when it's done a job, it automatically appears in front of screen, made me lose focus. How to disable auto appear? I've tried:
private void FrmMain_Activated(object sender, EventArgs e)
{
SendToBack();
}
But it was only after the program appear, bring it back to the rear. I want to prevent it bring to front from the firt. Please help me!
Related
We have some Forms that have no border / no toolbox (overlays)
Whenever the user clicks somewhere else in the underlaying window, the overlay-form is send to the background (regular non-modal-form behaviour)
Is there an Event for this, so the "overlay" could detect it's visibility change and close itself?
Maybe it can be handled within in resize / paint event, where the "invisibility" can be catched?
Background:
Typical "Select-Or-Create-New" UseCase. Clicking "plus" shows the tiny creation-form. Currently it's "topmost", so the user needs to hit "Escape" to get rid of it. (Else there would be a mess of "background-overlays", hence the question)
Would be more "userfriendly" if a click on something else closes that "tiny form":
You can use the Deactivate event of the form:
private void Form1_Deactivate(object sender, EventArgs e)
{
Visible = false;
}
I am coding a Windows form based application in C#.
When I click on the red cross(x) on the top right corner of the windows it should not stop the execution of the program. It should instead go to next part of the program. What do I need to do in order to have my program behave this way?
You can use the form closing event to cancel the closing of the form. In the designer click the lighting symbol in the properties and double click the form closing entry. This should make the code for you. It should make a function a bit like this:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
You need to add the e.Cancel that will stop the form closing
I have a DataGridView in my app and I can't scroll it using the mousewheel. It used to work fine before. I'm not sure what I have done to cause this because I only noticed it recently after I had made multiple changes to the code.
I'm not posting any code because there are more than 2k lines and I'm not sure where the error could possibly be.
Any ideas what might have caused this? If you need any code I can edit the question afterwards.
Almost certainly the problem occurs because the DataGridView has lost focus. This can be because another control on your form demands focus or your form is set by default to give a different control focus.
You can force the DataGridView to have focus. If you want to emulate the standard Microsoft Windows behavior of enabling mouse wheel scroll when the mouse is hovering over the control then just use the code below.
private void SettingsGrid_MouseEnter(object sender, EventArgs e)
{
dataGridView1.Focus();
}
If you want to scroll the grid regardless of what control has focus then the code will be similar to above with a little beak of tweaking.
Tell me please how to execute a method BackgroundAudioPlayer fastforward?
That is, how to do that when you long press the button, fast forward, and then release the button, the track nchinal play, in general as well as buttons work in the locked mode.
If you long press call as follows:
private void btnNext_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
BackgroundAudioPlayer.Instance.FastForward();
}
The track is scrolled to the end and pops up an error.
What is your desired behavior? You probably need some code on the MouseLeftButtonUp event to call Play to resume the playing of the current audio track.
I am having yet another problem with my application for my phone.
My problem is the following:
On one page I have a list of pictures, and a button marked as "favorite." If you are to favorite the particular image of the row, the border of the image changes colors to signify this.
However, whenever I tombstone my application or hit the back button and go back to that very same page, the borders of the images are back to their default color.
Now before you ask, I have no idea if this is an isolated memory problem. I have just begun looking into Isolated storage, and it's difficult for me to grasp at the moment.
Maybe this is a saving state problem?
Either way, I would like to have my application remember what the favorites are whenever a user exits the application or tombstones it, or hits the back button, etc.
Could someone please provide a piece of code in order to help with this?
You need to save your data because the system is basically killing your app. So you need in your app.xaml.cs write code to save and read your data in metods:
// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}