F9 Group Marketing and Technology Blog

Marketing, Technology, and current news at http://www.f9group.com/

Entries Tagged ‘windows-forms’

Set InitialDirectory for FolderBrowserDialog

The .NET FolderBrowserDialog class does not have an InitialDirectory property like the OpenFileDialog class.  But fortunately, it’s quite easy to set an initial folder in the FolderBrowserDialog: FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.RootFolder = Environment.SpecialFolder.Desktop; dialog.SelectedPath = @"C:Program Files"; if (dialog.ShowDialog() == DialogResult.OK) { Console.WriteLine( dialog.SelectedPath ); } Note that you can choose other RootFolder’s like MyComputer and MyDocuments.  Related posts: Adding Assemblies to the Visual Studio "Add Reference" Dialog Console Output from a WinForms Application The Proper Way to Show the Wait Cursor

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

C# WinForms Form Event Order

Sometimes it’s important to understand the order of events that occur when a WinForms Form is opened, closed, shown or hidden.  There are also a few “gotchas” that are important to know. Form Open Following is the order of events when a Form is opened.  Note that the Form’s Visible and IsDisposed property values are listed

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

Close All Forms in a Thread-Safe Manner

Closing all forms in an application seems like it would be a simple task of using a foreach loop in the Application.OpenForms collection, such as: foreach (Form form in Application.OpenForms) { form.Close(); } But there are two problems. First, the code above will throw an exception because the OpenForms collection changes each time you close a form,

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

Show ToolTip on TabPage in TabControl

So you’ve set the ToolTipText property of a TabPage in a TabControl.  When the user moves the mouse pointer over the tab, the text you specified is supposed to show in a tooltip.  But what if the tooltip is not showing?  Fortunately, this problem has an easy solution: Set the ShowToolTips property in the TabControl to

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

DataGridView HideSelection to Hide Selection when Grid Loses Focus

The DataGridView is a powerful grid control included in the .NET Framework.  One function missing, however, is the ability to hide the current selection when the DataGridView control is not focused.  What the DataGridView class needs is a HideSelection property, similar to the ListView and TextBox.  But the .NET designers have not included this capability in the DataGridView class. (more…) ShareThis

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz

Add Shaded Rows to ListView Details View

Sometimes it can be challenging to read the Details view in a ListView , especially if the rows are long.  This article shows how to add shading to every second row to make a ListView easier to read. (more…) ShareThis

Share and Enjoy:
  • Digg
  • Google
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • TwitThis
  • Blogsvine
  • description
  • E-mail this story to a friend!
  • Ping.fm
  • Print this article!
  • Slashdot
  • Yahoo! Buzz