Search results for 'Hook in the OnIdle method'. 1 post(s) found.
2007/09/25 14:59
The best way to enable and disable buttons, menu items and toolbar buttons
2007/09/25 14:59 in C#

Write an OnIdle method and put your GUI enable/disable code there. The OnIdle method is called every time your application's message queue becomes empty.
Hook in the OnIdle method in a Form's constructor by instantiating an EventHandler and adding that hander to the Application object's Idle property. Update the form's GUI in the OnIdle method. Finally, be sure to remove the EventHandler from the Application object's Idle property when the Form is about to close.
...
private EventHandler idleEventHandler;
...
public SettingsForm(InitialTabPage initialTabPage)
{
InitializeComponent();
...
idleEventHandler = new System.EventHandler(OnIdle);
Application.Idle += idleEventHandler;
}
...
private void OnIdle(object sender, EventArgs e)
{
// Update form's UI when program is idle.
deleteButton.Enabled = assemblyListBox.SelectedIndex != -1;
}
private void SettingsForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
...
Application.Idle -= idleEventHandler;
}
private EventHandler idleEventHandler;
...
public SettingsForm(InitialTabPage initialTabPage)
{
InitializeComponent();
...
idleEventHandler = new System.EventHandler(OnIdle);
Application.Idle += idleEventHandler;
}
...
private void OnIdle(object sender, EventArgs e)
{
// Update form's UI when program is idle.
deleteButton.Enabled = assemblyListBox.SelectedIndex != -1;
}
private void SettingsForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
...
Application.Idle -= idleEventHandler;
}
Another posts included in "C#"
| How to detect resource leaks in a Form (0) | 2007/09/25 |
| How to speed up access to the RichTextBox Lines property (0) | 2007/09/25 |
| Find Files in certain directory (0) | 2008/02/25 |
| How to exit from a console application (0) | 2007/09/25 |
| How to restrict a program to a single instance (0) | 2007/09/25 |
| Compress and decompress strings in C# (0) | 2007/09/25 |
| Graphics in C# - Irregular Forms (0) | 2007/09/25 |
| Extracting the Country from IP Address (0) | 2007/09/25 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/29 03:32
moneyideas
-
Subject different money making ideas
2010/01/29 12:37
moneyideas
-
Subject different money making ideas
2010/01/31 16:41
moneyideas
Prev

Rss Feed