Windows Forms FAQ

George Shepherd's Windows Forms FAQ

Welcome to the Windows Forms FAQ.  Questions and answers in this FAQ have been collected from newsgroup posts, various mailing lists and the employees of Syncfusion.  I have tried to mention the source wherever possible.  If you think that you should be credited for an answer, please send me a note and I will be happy to add a credit mention.

If you have a FAQ, or any other good Windows Forms resource, please e-mail me.  The Windows Forms FAQ forum is available if you need more information.

You can also access the ASP.NET FAQ Home WPF FAQ Home

Search Help
 

Windows Forms

  • Deployment
  • Controls
  • Books
  • Data Binding
  • Datagrid
  • Docking
  • Keyboard Handling
  • Layout
  • Licensing
  • Menus
  • Mouse Handling
  • from MFC
  • from VB6
  • Patterns
  • Printing
  • Resources
  • Scrolling
  • Common Dialogs
  • ListBox
  • ComboBox
  • RichTextBox
  • ListView
  • TreeView
  • Button
  • TabControl
  • TextBox
  • Cursors
  • WebBrowser
  • Tips
  • ProgressBars
  • PictureBox
  • Form
  • CheckedListBox
  • MDI
  • In IE
  • Smart Client
  • GDI+

  • Colors
  • Books
  • Brushes
  • Drawing Tips
  • Hit Testing
  • from GDI
  • Paths & Regions
  • Pens
  • Rendering Primitives
  • Bitmaps & Images
  • Fonts
  • Interoperability

  • Books
  • COM
  • Win32
  • Tools

  • Metadata Viewers
  • Other FAQs
  • Resource Editor
  • Design Time

  • Serialization
  • Custom Designers
  • Tips
  • Type Editors
  • UI
  • VS.NET

  • Debugging
  • Macros
  • Tips
  • Framework Tips

  • Performance
  • Events
  • CGI
  • General
  • General IO
  • Strings
  • Threading
  • XML
  • 1.1
  • Math
  • Network

  • Tips
  • 1. Windows Forms Deployment

      

       1.1How can I run an EXE from within my application?
       1.2What are the common issues in redirecting assemblies using the publisher policy files?
       1.3How can I get a list of all processes running on my system?
       1.4How can I find all programs with a GUI (not just arbitrary windows) that are running on my local machine?
       1.5How can I make sure there is only one instance of my application running?
       1.6How do I determine which operating system is running?
       1.7How can I get all IP addresses for my local machine?
       1.8My user does not have .NET installed. Will he be able to run my Windows Forms application?
       1.9How do I get the path to my running EXE?
       1.10How can I programmatically obtain the name of the assembly that the code is executing in ?
       1.11How can I see what is installed in the Global Assembly on a machine?
       1.12How do I set the company name that is returned by System.Windows.Forms.Application.CompanyName?

    2. Windows Forms Controls

      

       2.1How do you prevent serialization of certain child controls in your Composite Control?
       2.2How do I get hold of the currently focused Control?
       2.3Why do calling Focus() on a control not set focus on it?
       2.4How do I listen to windows messages in my Control?
       2.5How do I programatically change the color of a control?
       2.6How can I change the Border color of my control?
       2.7Why should I provide a Non-Client border to my Control derived class?
       2.8How do I provide a 2 pixel 3d border in the Non-Client area of my Control derived class?
       2.9How do I provide a 1 pixel border in the NonClient area of my Control?
       2.10How do I invalidate a control including it's NonClient area?
       2.11How can I implement a scrollable picture box?
       2.12How can I put Controls, a ProgressBar for example, into a StatusBar?
       2.13How do I implement an ownerdrawn statusbar so I can put a progressbar in it?
       2.14How would I change the icon that appears on the toolbox for a custom control?
       2.15I would like to prevent validation in my textbox when the user clicks on my Cancel button, how do I do this?
       2.16A control's Validating event is hit even when the user clicks on the Close box. How can I avoid this behavior?
       2.17Why does adding images to an ImageList in the designer cause them to lose their alpha channel?
       2.18Why do the XP Icons that have alpha channel not draw properly when associated with controls like ListView?
       2.19Why do the XP Icons when drawn using Graphics.DrawImage not draw transparently?
       2.20How do I prevent resizing of my Controls by the user, via Docking or anchoring or manual resizing during design-time?
       2.21How do I listen to the screen resolution change in my control?
       2.22How do I determine which button in a Toolbar is clicked?
       2.23I set a Control's Visible property to true and in the immediate next statement, it returns false. Why doesn't setting the Visible property 'take'?
       2.24I'm trying to make the background of my linklabel transparent so a picturebox will show through it. However, if I set the link label's BackColor property to Transparent the label still has a white background. Why?
       2.25How do I dynamically load a control from a DLL?
       2.26How can I make my controls transparent so the form's background image can show through them?
       2.27How do I create an editable listbox with an in-place TextBox and Button?
       2.28What control do I use to insert Separator lines between Controls in my Dialog?
       2.29How can I programmatically manipulate Anchor styles?
       2.30What is the best method to override in custom Controls to perform custom initialization during runtime?
       2.31How do I determine the width/height of the Non-Client area (like the border in a textbox) of a Control?
       2.32What is the (DynamicProperties) item listed on a control's property page in VS.NET?
       2.33In the property browser for a custom control, how do I disable a property initially, but enable it later based on some other property changing?
       2.34How can I have the control designer create the custom editor by calling the constructor with the additional parameters rather than the default constructor?
       2.35How can I make a Panel or Label semi-transparent on a Windows Form?
       2.36How do I make the arrow keys be accepted by a control (such as a button) and not handled automatically by the framework's focus management?
       2.37How can I add a control to a Window Form at runtime?

    3. Windows Forms Books

      

       3.1Windows Forms Programming in C#?
       3.2Programming Microsoft Windows with C#?
       3.3C# Design Patterns?

    4. Windows Forms Data Binding

      

       4.1Does MySql work with ADO.NET?
       4.2Where can I find a discussion of databinding and windows forms?
       4.3How do I test for a null value in DataView.RowFilter?
       4.4I don't have SQL Server. Is there any way to run the samples that need SQL server?
       4.5How can I import a CSV file into a DataTable?
       4.6How can I prevent a ComboBox and DataGrid bound to the same DataTable from sharing the same current position?
       4.7I get a 'This would cause two bindings in the collection to bind to the same property' error message. What might cause this?
       4.8How do I bind a TextBox to a nested relation?
       4.9How do I call a SQL stored procedure?
       4.10I programatically change a bound TextBox value, but the value does not get pushed back into the bound datasource. How can I make sure the DataSource is updated?
       4.11Why does the CheckedListBox lose checked state when placed in a tab page that gets hidden and shown?
       4.12How do I bind a mdb file to a datagrid?
       4.13How do I bind a listbox or a combobox to a MDB file?
       4.14In my databound ComboBox, how do I set the SelectedItem property?
       4.15Are server side cursors supported in .NET?
       4.16I am populating a ListBox by binding it to an ArrayList. The initial display is OK, but later changes to my ArrayList are not shown in my ListBox. How can I get the changes to show properly?
       4.17My SQL server runs on a non-default port. How can I specify this port in my connection string?
       4.18What is a DataSet?
       4.19How do I add updating support to a dataset?
       4.20How can I programmatically move through a dataset that has bound controls?
       4.21When I try to update a dataset I get an error that the system is unable to find "Table"?
       4.22How can I bind an ArrayList to a DataGrid?
       4.23When I try to bind two comboboxes to the same datatable, both boxes show the same values, changing one changes the other. How do I make them have distinct values?

    5. Windows Forms Datagrid

      

       5.1How can I programatically set the rowheight of a row in my DataGrid?
       5.2How can I autosize the rowheights in my datagrid?
       5.3How do I prevent sorting a single column in my DataGrid?
       5.4How do I programmatically select a row in DataGrid?
       5.5How can I translate a point to a cell in the datagrid?
       5.6I lost the settings in my DataGrid set during design-time?
       5.7How do I prevent a click into the grid highlighting a cell?
       5.8How do I prevent the datagrid from displaying its append row (the row at the end with an asterisk)?
       5.9How can I catch a double-click into a column header cell?
       5.10How can I select the entire row when the user clicks on a cell in the row?
       5.11How can I get text from a column header in a MouseUp event?
       5.12How do I hide a column?
       5.13How do I color a individual cell depending upon its value or some external method?
       5.14How can I put a checkbox in a column of my DataGrid?
       5.15How can I restrict the keystrokes that will be accepted in a column of my datagrid?
       5.16How do I make a field auto increment as new rows are added to my datagrid?
       5.17How can I prevent a particular cell from being editable?
       5.18How do I move columns in a datagrid?
       5.19How can I do cell by cell validation in a datagrid?
       5.20How do I programmatically determine the selected rows in a datagrid?
       5.21How can I bind the datagrid to a datasource without using any wizards?
       5.22How can I bind two datagrids in a Master-Detail relationship?
       5.23How do I get the row or column that has been clicked on?
       5.24How do I add an unbound column to my bound datagrid?
       5.25How do I get the row and column of the current cell in my datagrid?
       5.26How can I prevent the Enter key from moving to the next cell when the user is actively editing the cell and presses Enter?
       5.27How do I set the width of a column in my DataGrid?
       5.28How can I implement OLE Drag & Drop between a DataGrid and another OLE DnD object that supports the Text format?
       5.29How can I tell if the current row has changed and whether I am on the AddNew row or not?
       5.30How do I hide the gridlines or set them to a particular color?
       5.31How can I get the selected text in an active gridcell?
       5.32How do I determine whether a checkbox in my datagrid is checked or not?
       5.33How can I move rows by dragging the row header cell?
       5.34How can I control the cursor over my DataGrid?
       5.35After scrolling with the mouse wheel on a selected row in a DataGrid I cannot get it back into view. Is there a work around?
       5.36How can I make the DataGrid column be blank and not display (null) as the default value?
       5.37How can I add a DateTimePicker column style to the DataGrid?
       5.38How can I put a combobox in a column of a datagrid?
       5.39I want to do custom handling of special keys such as the Tab key or F2 in the TextBox of a column in the DataGrid. How do I subclass this TextBox to get at it virtual members?
       5.40How can I have a column of icons in my datagrid?
       5.41How can I make my DataGrid support a single select mode, and not the default multiselect mode?
       5.42How can I get celltips or tooltips to vary from cell to cell in my DataGrid?
       5.43How can I get notification of the changing of a value in a column of comboboxes within my datagrid?
       5.44How can I make the datagrid have no currentcell?
       5.45How can I make my grid never have an active edit cell and always select whole rows (as in a browser-type grid)?
       5.46I have hidden (column width = 0) columns on the right side of my datagrid, but tabbing does not work properly. How can I get tabbing to work?
       5.47How can I get the number of rows in my DataGrid?
       5.48How do I format a date column in a datagrid?
       5.49How can I change the width of the row headers or hide them?
       5.50How do I catch a doubleclick in my datagrid?
       5.51How can I make my last column wide enough to exactly occupy all the client area of the datagrid?
       5.52How can I prevent my user from sizing columns in my datagrid?
       5.53How can I catch the bool values changing in a DataGridBoolColumn?
       5.54When I click on a row header, the row is selected and no cell is active. How can I do this programmatically?
       5.55How can I force the vertical scrollbar in my DataGrid to always be visible?
       5.56How can I autosize a column in my datagrid?
       5.57How can I get rid of the error icon that appears when there is an editing error?
       5.58How do I find the top-left visible cell in a datagrid?
       5.59I want to display negative values with a CR suffix, instead of a minus sign. How can I perform custom formatting on the cells in my datagrid?
       5.60I want to do sort of a database join of two tables. How can I use data from two DataTables in a single DataGrid?
       5.61How do I display a column of buttons such as pushbuttons or combobox buttons?
       5.62How can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key?
       5.63How can I enable column selections in my datagrid?
       5.64How do I programmatically scroll the datagrid to a particular row?
       5.65How can I place text in the rowheader column of my datagrid?
       5.66How do I set default values for new rows in my datagrid?
       5.67How do I iterate through all the rows and columns in my datagrid?
       5.68How can I specially color only the currentcell of my readonly datagrid?
       5.69How can I make the Enter Key behave like the Tab Key and move to the next cell?
       5.70How do I use the DataColumn.Expression property to add a computed/combined column to my datagrid?
       5.71How can I change the font used in a grid cell on a cell by cell or row by row basis?
       5.72How can I use a mouse to select cell ranges in my datagrid?
       5.73How do I determine the DataGridTableStyle MappingName that should used for a DataGrid to make sure the grid uses my tablestyle?
       5.74I have a derived DataGridColumnStyle. From within my Paint override, how can I get at other values in the DataGrid?
       5.75How do I retrieve the current row from a DataTable bound to a DataGrid after the grid has been sorted?
       5.76How can I catch when the user clicks off the grid, say to close the form?
       5.77How can I get a CheckBox column in a DataGrid to react to the first click?
       5.78How can I use events to restrict key input to grid cells?
       5.79How can I format columns in my DataGrid without explicitly adding DataGridColumnStyles?
       5.80How can I auto-adjust keyboard input? For example, make typing 12312002 be taken as a valid date, 12/31/2002.
       5.81Can I display the rows in my datagrid in a free-form layout using textboxes on a panel?
       5.82How can I tell whether a scrollbar is visible in my DataGrid is visible?
       5.83How do I autosize the columns in my DataGrid so they always fill the the grid's client area?
       5.84How can I prevent all the cells in my DataGrid from being edited without deriving GridColumnStyle?
       5.85How can I prevent the plus-minus icon that appears next to the row header when I have a datagrid displayed bound to a datasource that has a relation defined?
       5.86How can I display master-details-details in three separate grids?
       5.87In my datagrid, if I press tab to enter a column using a derived columnstyle, the column does not receive focus. Why?
       5.88How can I detect when a cell starts being edited, not when it becomes current?
       5.89How can I have a column of bitmaps in a DataGrid?
       5.90How can I add my custom columnstyles to the designer so I can use them in my DataGrid at design time?
       5.91How can I programatically add and remove columns in my DataGrid without modifying the DataTable datasource?

    6. Windows Forms Docking

      

       6.1How can I make a control occupy all the client area of a form?
       6.2How can I make my control automatically grow when the parent form is sized?
       6.3What is the difference between a form's Anchor property and a form's Dock property?

    7. Windows Forms Keyboard Handling

      

       7.1How can I prevent a control from getting a particular keystroke?
       7.2How can I tell if an ALT, Shift or CTL key is pressed without catching an event?
       7.3How do I check the state of the virtual keys, Caps lock for example?
       7.4How can I simulate keyboard input in my application?
       7.5How can I catch keyboard messages on a application-wide basis?
       7.6How can I listen for certain keys at the Form level irrespective of which Control has the focus?

    8. Windows Forms Layout

      

       8.1How can I programmatically set the initial position of a Form so that it is displayed properly after calling ShowDialog()?
       8.2How do I create a custom layout engine?
       8.3I have a form with several controls on it. As I size the form, the controls are being resized continuously. Is it possible to postpone changing the controls position until the resizing is complete?

    9. Windows Forms Licensing

      

       9.1How does .NET support licensing?
       9.2How do I find the file version of an EXE?

    10. Windows Forms Menus

      

       10.1How do I clone menus, insert menus, use popup menus, etc.
       10.2How do I add a context menu to a control?
       10.3When using the ContextMenu on multiple Controls, how do I know on which Control the right click was performed?
       10.4How do menu shortcuts work?
       10.5How do I prevent the context menu from showing up on certain keyboard keys (like Keys.Apps)?
       10.6How do I know when a menu is closed/started so that I can refresh my status bar?
       10.7How do I make the context menu appear only when clicked at certain portions of the Control?
       10.8How to add a Separator in a menu?
       10.9How can I add an icon to my menu items?
       10.10How do I cancel a context menu programatically?
       10.11Is there an easy way to create the "Window" menu that shows the list of child forms open?
       10.12Is there an Idle event which will get fired from which I could update my menu item's enabled state?
       10.13How can I work around my menu shortcuts from showing up incorrectly when I use Ctrl+Number?
       10.14How do I control the position of the context menu when it is invoked via the keyboard?
       10.15How do I disable the default context menu of a textbox?
       10.16How can I make the context menu to close after a set time interval?
       10.17How can I enable the mnemonics (underline) to show when my application is launched?

    11. Windows Forms Mouse Handling

      

       11.1How can I resize a borderless form with a rubber-band effect?
       11.2How do I get a mouse cursor position in my control's client coordinates?
       11.3How can I catch the mouse being over a control?
       11.4How do I set the mouse cursor position?
       11.5How can I reset the OnMouseHover timer so that it will fire again without the mouse having to leave the client area of a control?
       11.6How can I drag a window if it doesn't have a title bar or border?
       11.7How can I determine if a mouse button is pressed and moving over my form?
       11.8Why am I not receiving MouseLeave messages in a Control in my Form?

    12. Windows Forms from MFC

      

       12.1As a VC++ programmer, what should I look out for when using C#?
       12.2Where can I find a succinct discussion of Windows Forms?
       12.3When I add a destructor to a class, why isn't it hit when my instantiated object goes out of scope?
       12.4How do I convert a string to a double or int? What plays the role of atof and atoi in C#?
       12.5What class or method do I use to retrieve system metrics like the width of a scrollbar?
       12.6In C++, the code "MyClass ht;" creates an object ht on the stack frame. But in C#, this same code compiles, but gives a runtime error. Why?
       12.7I need to encode the LParam argument of a mouse message. How do I do MakeLong , HiWord and LoWord type conversions?
       12.8How do you clear the contents of a list box?

    13. Windows Forms from VB6

      

       13.1How do I draw a line in VB7 as there is no Line command as there was in VB6?
       13.2What is the replacement for VB6's SendKeys statement?
       13.3In VB6, I used control arrays to have a common handler handle events from several controls. How can I do this in Windows Forms?
       13.4What is different about working with forms in VB.NET? For example, how can I reference one form from another form?

    14. Windows Forms Patterns

      

       14.1How to display a status dialog in a background thread during a long operation and allow the user to cancel?
       14.2How can I throw my events asynchronously?
       14.3Why are the Tooltips not being shown on a NumericUpDown control?
       14.4How to get the hyperlink and the hyperlink text dragged from IE in my Control's drag-drop event?

    15. Windows Forms Printing

      

       15.1How do I print a form?
       15.2How do I display the PrintPreview maximized and control its zooming?

    16. Windows Forms Resources

      

       16.1What are the steps to compiling and using multiple language resources?
       16.2How do I load a BMP file that has been added to my solution as an embedded resource?
       16.3Why doesn't a Form containing an ImageList not open in WinRes?
       16.4How do I embed a manifest file into my exe?
       16.5How can I save a temporary disk file from an embedded string resource?
       16.6How do I read embedded resources?
       16.7How can I check if a certain resource is included in a assembly?
       16.8Where can I find information on globalization?
       16.9How do I read or write resources from code?
       16.10How do I create resources to make culture-aware programs without re-compiling code?
       16.11How do I programmatically use resources to make my programs culturally aware?
       16.12How can I dynamically load a resource file?

    17. Windows Forms Scrolling

      

       17.1How do I add support for custom scrolling to my own user control?
       17.2Are there any events that get fired when the user scrolls?

    18. Windows Forms Common Dialogs

      

       18.1How do I use the ColorDialog to pick a color?
       18.2How do I use the FontDialog class to set a control's font?
       18.3How do I implement a Folder Browser class?
       18.4How can I get just the name of a file from the complete path string?
       18.5How can I get just the extension of a file from the complete path string?
       18.6How do I use the OpenFileDialog?
       18.7How do I specify the path for the FolderBrowser instance when it opens the first time?

    19. Windows Forms ListBox

      

       19.1How do I add and delete items from a ListBox?
       19.2How do I implement Drag and Drop support between ListBoxes?
       19.3How can I drag file names from Windows Explorer and drop them into a listbox?
       19.4How do I implement an ownerdrawn listbox?
       19.5How can I set the width of a listbox to fit the text?

    20. Windows Forms ComboBox

      

       20.1How do I bind the values of an enum to a ComboBox?
       20.2How can I programmatically prevent the combobox from dropping?
       20.3How can I adjust the height of the of my ComboBox dropdown?
       20.4How do I implement an owner drawn combobox?
       20.5How do I add a ComboBox button to a toolbar?
       20.6How do I set the width of a combobox to fit the entries in its list?
       20.7How can I programmatically create a new list for my ComboBox dropdown?
       20.8How can I turn off editing in the textbox portion of a ComboBox, restricting the user to selecting only those options in the drop list?

    21. Windows Forms RichTextBox

      

       21.1How can I create and save a RTF file?
       21.2How can I get a string that contains RTF format codes into a RichTextBox?
       21.3How do I make the RichTextBox support drag and drop?
       21.4How do I set the color and font in a RichEditBox?
       21.5How can I change the FontStyle of a selection without losing the styles that are present?
       21.6How can I programmatically position the cursor on a given line and character of my richtextbox?
       21.7Where can I find more information on the RTF specification?
       21.8How can I add a hyperlink to a RichTextBox control?
       21.9How can I print my rich text?
       21.10How can I load an embedded rich text file into a richtextbox?

    22. Windows Forms ListView

      

       22.1How do I add SubItems to a ListView control?
       22.2When I call ListViewItem.Selected = true;, why doesn't the item get selected?
       22.3How do I unselect the selected items in a ListView programatically?
       22.4I am trying to programmatically change the ForeColor and BackColor properties of subitems in a listview. Why doesn't this work?
       22.5How do I implement custom column sorting in a listview?
       22.6How do I programmatically select an item in my listview?
       22.7How can I sort a column in a ListView?
       22.8How can I tell which column (subitem) has been clicked on in my listview?

    23. Windows Forms TreeView

      

       23.1How do I make the TreeView scroll when I drag an item to the top or bottom?
       23.2How do I implement Drag and Drop support between two TreeViews?
       23.3How do I display checkboxes in the nodes of a treeview?
       23.4When I right-click a tree node, it does not become selected. How can I make it be selected on a right-click?
       23.5When I get the SelectedNode in the treeview's Click event, it is the old selection. How do I get the newly selected node?
       23.6How can I get a tooltip to vary from node to node in my treeview?
       23.7How can I determine the node level of a node in my treeview?
       23.8How can I populate a TreeView Control with XML Data?
       23.9How can I clone/copy all the nodes from one TreeView Control to another?
       23.10How do I programmatically select a node in a TreeView control?
       23.11Can I select multiple nodes in a TreeView Control?
       23.12How can I display a context menu when the user right-clicks on a node in the TreeView control?
       23.13How can I ensure that a node is selected when the user clicks along the line of a node?

    24. Windows Forms Button

      

       24.1How do I autosize a button to fit its text?
       24.2How can I decorate a button face with custom drawing?
       24.3How can I put a bitmap or icon on a button face?
       24.4How can I trigger a button click event?
       24.5How can I get button to fire a click event at specific time intervals while the mouse is down like a scrollbar button?

    25. Windows Forms TabControl

      

       25.1How do color the tabs on my TabControl?
       25.2How can I drag and drop TabPages between TabControls?
       25.3For a TabControl, how do I make the tabs on the tab pages appear on the bottom instead of on the right?
       25.4How do I use code to insert or delete tabpages in a TabControl?
       25.5How do I dynamically hide/unhide tabs in a TabControl?
       25.6How do I prevent the user from changing the selected tab page?
       25.7Why do the order of the tabs keep changing when opening and closing the Form?
       25.8How do I force the focus to be on a text box in a tab page when the application gets loaded?
       25.9How do I programatically select a Tab Page?

    26. Windows Forms TextBox

      

       26.1How can I prevent the beep when enter is hit in textbox?
       26.2How can I disable the right-click context menu in my textbox?
       26.3How do I disable pasting into a TextBox (via Ctrl + V and the context menu)?
       26.4How do I format numbers, dates and currencies in a TextBox?
       26.5How do I browse for, and read a text file into an TextBox?
       26.6How do I send a EM_XXXX message to a textbox to get some value such as line index in C#?
       26.7How do I prevent a control from receiving focus when it receives a mouseclick?
       26.8How do I make my textbox use all upper (or lower) case characters?
       26.9I have a delete key shortcut for my main menu. When my textbox is being edited, pressing delete activates this menu items instead of being processed by the TextBox. How can I get my TextBox to handle this delete?
       26.10How can I use a TextBox to enter a password?
       26.11How can I place a TextBox in overwrite mode instead of insert mode?
       26.12How can I restrict the characters that my textbox can accept?
       26.13How do I set several lines into a multiline textbox?
       26.14When I set a TextBox to Readonly or set Enabled to false, the text color is gray. How can I force it to be the color specified in the ForeColor property of the TextBox.
       26.15How can I make the focus move to the next control when the user presses the Enter key in a TextBox?
       26.16How can I make a ReadOnly TextBox ignore the mousedowns so that you cannot scroll the text or set the cursor?

    27. Windows Forms Cursors

      

       27.1I set the wait cursor using Cursor.Current = Cursors.WaitCursor;. Why does does it disappear before I want it to?
       27.2How do I change the cursor for a control?
       27.3How to convert a Cursor class to a .cur file?
       27.4How to load and display a cursor from a resource manifest?

    28. Windows Forms WebBrowser

      

       28.1How can I host a WebBrowser control in a Windows Form?
       28.2How can I enable editing for the WebBrowser?
       28.3How can I catch the BeforeNavigate2 event?
       28.4WebBrowser control does not seem to be cleaning up temp files. How can this be done?
       28.5How can I use MSHTML to edit HTML in a Windows Forms control?

    29. Windows Forms Tips

      

       29.1How do I write a screen saver?
       29.2How do I determine the screen resolution?
       29.3How do I determine the working area of a screen without the systemtray area?
       29.4How do I position my form to the bottom right of the screen when it opens up the first time above the system tray?
       29.5How do I change my screen's resolution programatically?
       29.6How do I determine the current date/time?
       29.7How do I determine the time taken for a long operation that I perform?
       29.8What are the implications of using the Timer class in System.Timers as opposed to the Timer class in System.Windows.Forms?
       29.9Is there an easy way to Create/Delete/Move files in the Windows File System?
       29.10How can I use XP Themes with Windows Forms using the .NET FrameWork 1.1?
       29.11How can I use XP Themes with Windows Forms using the .NET FrameWork 1.0?
       29.12How do I use Windows Forms Controls in Internet Explorer?
       29.13Why would I be getting a NullReferenceException in Windows Forms with no application code in the call stack?
       29.14Can working on WinForms and .Net in general get exciting?
       29.15What mechanisms does .Net provide to convert one type to another?
       29.16How can I display HTML in a Form?
       29.17The MessageBox always appears in the center of the screen. How can I change it's location?
       29.18If I have a button with &Next as the text, the N-accelerator key does not appear until I press Alt. Why?
       29.19When I try to catch the Resize event to handle sizing of MDI children, the event is called even before my form's constructor can create the children throwing an exception. How do I avoid this?
       29.20How can I tell if the user has changed some system preference such as the locale or display settings?
       29.21Its possible that some of my class members will not be initialized when one of my virtual members gets called even before the constructor. How can I avoid this?
       29.22In a Hashtable, why doesn't setting the value for an existing key to be null remove the key from the Hashtable?
       29.23How do I change a directory name?
       29.24How do I beep the computer's speaker in a Windows Form application?
       29.25How do I use the system clipboard?
       29.26How do I add an application to the Window's Tray?
       29.27How can I shut down/restart the OS from my Windows Forms Application?
       29.28How can I add a custom verb to the file and folder context menus in the explorer shell?
       29.29How do I create windows shortcuts on my desktop programatically in .Net?
       29.30I have a long loop. How can I make my application continue to process events while it is executing this loop?
       29.31I get a message 'DragDrop registration' failed. Why?
       29.32What is the purpose of the [STA Thread] attribute for the Main method of a C# program?
       29.33I add my application to the Window's Tray, set ShowInTaskBar to false, but the program still appears in the Alt+Tab list.

    30. Windows Forms ProgressBars

      

       30.1How can I implement a smooth ProgressBar?

    31. Windows Forms PictureBox

      

       31.1How can I place a border around a PictureBox?
       31.2How can I copy a bitmap from the clipboard to a PictureBox?
       31.3How can I copy and paste images/graphs etc from MS Office to a PictureBox?
       31.4How can I drag and drop an image from one PictureBox to another?

    32. Windows Forms Form

      

       32.1How can I programmatically maximize or minimize a form?
       32.2How can I display a pop up a confirmation dialog when the user closes the form?
       32.3How can I center my form?
       32.4How do I prevent users from resizing a form?
       32.5How do I programmatically set an image as Form's Icon ?
       32.6How can I add items to the System Menu of a form.
       32.7How can I have a form with no title bar, but yet keep the resizing borders?
       32.8How can I tell if a form is closed from the controlbox (system menu) or from a call to Form.Close?
       32.9I have two forms. How can I access a textbox on one form from the other form?
       32.10How do I create a non-modal top level form that always stays on top of all the app's windows (like the VS.Net find dialog)?
       32.11How can I display a form that is 'TopMost' for only my application, but not other applications?
       32.12How do I automatically resize the Form when the screen resolution changes between design-time and runtime?
       32.13How can I ensure that my form will always be on the desktop?
       32.14How can I restrict or control the size of my form?
       32.15How can I prevent a form from being shown in the taskbar?
       32.16How do I prevent a user from moving a form at run time?
       32.17How can I create a non rectangular form?
       32.18How can I make my form cover the whole screen including the TaskBar?
       32.19How can I move a Borderless form?
       32.20How do I force a Windows Form application to exit?
       32.21How do I set the default button for a form?
       32.22How do I get an HWND for a form?
       32.23How can I detect if the user clicks into another window from my modal dialog?
       32.24How do I create a form with no border?
       32.25How do I prevent a Form from closing when the user clicks on the close button on the form's system menu?
       32.26How do I display a splash screen type form, one with only client area (no border or titlebar)?
       32.27How do I get the window handle (HWND) of my form or control?
       32.28How can I make sure I don't open a second instance modeless dialog that is already opened from my main form?
       32.29Is there a way to halt a screen from painting until all the controls on the form are initialized?
       32.30How do I return values from a form?
       32.31How can I easily manage whether controls on my form are readonly or not?
       32.32The controls that I've try to add to my form at runtime don't show up. What's wrong?
       32.33Setting Form.Visible to false does not make my main form start up invisibly. How can I make my main form start up invisibly?
       32.34How to make a form transparent?
       32.35How can I create an instance of a Form class just from knowing its name in a string?
       32.36I don't want to have the Close box on my form's title bar. How do I remove this system menu box?
       32.37How do I change my application's icon?

    33. Windows Forms CheckedListBox

      

       33.1How do I check/uncheck all items in my checkedlist?

    34. Windows Forms MDI

      

       34.1How can I create an MDI application in the .NET framework with C#?
       34.2I have an MDI application with several child forms. The child form's Activated event is not being fired consistently as different child forms are activated. What's wrong?
       34.3In an MDI application, the MDI child's MaximumSize and MinimumSize properties don't seem to take effect. How can I restrict the size of my MDI child?
       34.4How do I check to see if a child form is already displayed so I don't have two instances showing?
       34.5I need to perform certain custom processing whenever an MDI child form is added to/removed from the MDIContainer form. How do I determine this?
       34.6How do I paint in my mdi container, a logo, for example?
       34.7How do I make my child Form fill the entire mdi client without being maximized?
       34.8How can I change the background of my MDI Client container?

    35. Windows Forms In IE

      

       35.1Where can I get information on hosting Windows Forms Controls in IE?
       35.2How do I clear the download cache in my client machine?
       35.3How can I use a WinForms Control in IE?
       35.4What are some common gotchas while trying to embed a Windows Forms Control in IE?
       35.5What are some common UI limitations while running code in the Internet Zone?

    36. Windows Forms Smart Client

      

       36.1Where are the getting started info. on Smart Client Deployment?

    37. GDI+ Colors

      

       37.1I need to save a color as a string and be able to retrieve it. How can I do this?
       37.2How do I convert a color to integer and vice-versa?
       37.3How do I desaturate a specific color?
       37.4What is alpha blending?
       37.5Is there a way to find out the brightness of a Color?
       37.6How can a translate an OLE_COLOR into a GDI+ Color object?
       37.7How do you translate a HSB color to RGB?
       37.8Is there a way to force some contrast between two colors (like background color and foreground color)?

    38. GDI+ Books

      

       38.1GDI+ Programming: Creating Custom Controls using C#?
       38.2Programming Windows with C#?

    39. GDI+ Brushes

      

       39.1How do I use hatched and gradient brush types?
       39.2How to set the rendering origin for hatch brushes?
       39.3How to create my own hatch styles for brushes?

    40. GDI+ Drawing Tips

      

       40.1Where can I see a basic tutorial on GDI+?
       40.2What are some things to remember when drawing in Window Forms?
       40.3When can I not use AutoScrolling? In other words why would I ever need any other form of autoscrolling?
       40.4Are AutoScrolling bounds setup in World or Device coordinates?
       40.5Why am I not being able to set a Color.Transparent color as a background to my control?
       40.6Why does a Control not draw transparent even after setting it's BackColor to Transparent?
       40.7Why does my transparent Panel whose parent has a gradient background flicker a lot when resized?
       40.8How do I get a count of the gdi handles currently in use in my application?
       40.9How can I get the screen resolution of my display?
       40.10How can I minimize flickering when drawing a control?
       40.11How do I draw circles, rectangles, lines and text?
       40.12How do I get a snapshot of my desktop?
       40.13How do I draw rotated text?
       40.14How can I draw without handling a paint message?

    41. GDI+ Hit Testing

      

       41.1How to HitTest a polygonal region?

    42. GDI+ from GDI

      

       42.1How does text drawing differ between GDI+ and GDI?
       42.2How do I do XOR-type-drawing (SetROP2-Function in MFC) in GDI+?
       42.3Can I mix GDI and GDI+ drawing in my application?
       42.4How do the Win32 System Colors map to the colors provided by System.Drawing.SystemColors?

    43. GDI+ Paths & Regions

      

       43.1What is a GraphicsPath?
       43.2How can I create non-rectangular windows?
       43.3Is there a imagemap like control in Windows Forms?

    44. GDI+ Pens

      

       44.1Using a wide pen, how do I draw a series of line segments with rounded corners?
       44.2With a wide pen, how can I control how the endpoints of my line appear?

    45. GDI+ Rendering Primitives

      

    46. GDI+ Bitmaps & Images

      

       46.1How do I create a "Negative" representation of my image?
       46.2How do I draw my bitmap in a disabled state?
       46.3How can I programmatically create a bitmap?
       46.4How can I swap colors in a bitmap or icon?
       46.5How do I create a new image off a base image with certain portions of the base image modified, in code?
       46.6How do I extract a Bitmap from an icon of a specific size?
       46.7How to draw a shadow for a given transparent image?
       46.8How to draw a faded image?
       46.9How do I programmatically load, modify and save a bitmap?
       46.10How do I draw an image with a gray scale?
       46.11How do I get the color of a pixel in my bitmap?
       46.12How do I create a new bitmap with a new size based on an existing bitmap?
       46.13How can I read individual frames from an animated image?
       46.14How do I capture a bitmap of my form?
       46.15How do I overlay one bitmap over another?
       46.16How can I create a thumbnail of a bitmap?

    47. GDI+ Fonts

      

       47.1How do I set the font for a control?
       47.2When I try to set a particular font style, say italics, I get an error message "Property cannot be assigned to -- it is read only". How can I set this read only property?
       47.3MeasureString seems to have problems with white space and punctuation. Is there a better method to use?
       47.4How can I draw a single line of text with different fonts using DrawString?
       47.5How do I display adjacent text?
       47.6How can I fill a combobox with available fonts?
       47.7How can I draw font samples from the available fonts?

    48. Interoperability Books

      

       48.1Are there any books out there that focus on COM interop?

    49. Interoperability COM

      

       49.1How do you invoke a COM Class in a specific COM DLL in .Net?
       49.2How do you dynamically invoke a COM class from its GUID?
       49.3How do you make .Net components that could be used by COM?
       49.4How can I read and display Excel files from within my C# application?
       49.5Should I try to use Interoperability or migration to use COM with .NET?
       49.6How can I get events fired by an Office XP chart control hosted in my Windows Forms app?

    50. Interoperability Win32

      

       50.1How to add an extern reference to a Win32 API?
       50.2How do I hit a web page from within a button handler in my Windows Forms application?
       50.3How can I capture output from an arbitrary console application from within my Window Form application?
       50.4How do I convert LParam in a message from IntPtr to the Win32 type?
       50.5How do I maximize my main window?
       50.6How can I use 'Hooks' in .NET?
       50.7Is there any way to get to the Edit control or the editHandle of a ComboBox using safe code?
       50.8How do I get the associated Icon from a file in the file system?
       50.9How can I get the directory name for "My Documents" folder and other system directories?
       50.10How can I show a form without making it active?
       50.11How to access a winapi that has a LPTSTR and maxlen param?
       50.12How do I use an exported function (extern "C") from a legacy DLL?
       50.13How can I draw outside my WIndow?
       50.14Is there any way to get detailed error information for Win32 errors when using Platform Invoke?

    51. Tools Metadata Viewers

      

       51.1Are there any tools that allow me to view the rich meta data that .NET assemblies have? Is there a OLEVIEW equivalent for .NET?
       51.2How do I disassemble a .net assembly (dll/exe) into the IL format?
       51.3How do I create a dll/exe off a previously diassembled .il file?
       51.4How can I launch ILDASM from the VS.NET 2003 IDE?

    52. Tools Other FAQs

      

       52.1Are there any easy to use Unit Testing frameworks available for .NET applications?
       52.2Are there any easy to use build tools for .NET applications?
       52.3Are there tools available for generating class library documentation for .NET applications?
       52.4How can I generate PDF files from my .NET application?
       52.5CVS integration using C#?
       52.6How can I read and write zip files in my Windows Forms program.

    53. Tools Resource Editor

      

       53.1I don't like the resource Editor that comes with Visual Studio.NET. Are there any alternatives out there?

    54. Design Time Serialization

      

       54.1How to make my Component add itself to the contained Form's IContainer list?
       54.2How do I prevent the default values of my Localized properties form being set?
       54.3How do I force the changes in base class fields to be serialized via a base class property in the inherited type's designer?

    55. Design Time Custom Designers

      

       55.1How do I implement a custom designer?
       55.2How can I insert custom menu items (verbs) into my Component/Control designer's Context Menu in design time?
       55.3How do I control the state of my custom verb in my designer?
       55.4How do I restrict my Container Control to parent only certain types of Controls, and vice-versa, during design-time?
       55.5How do I prevent the Designer-Grid from being drawn on my Container Control during design-time?
       55.6How do I get Mouse Messages on my Control during design-time?
       55.7Can I do some custom drawing on my control designer's surface during design-time?
       55.8How can I know when a Control/Component has been selected in the designer surface?
       55.9How do I prevent resizing of my Control in the designer?
       55.10I have created a usercontrol and a designer, How can i debug the designer?

    56. Design Time Tips

      

       56.1When a property gets modified, how do you refresh other properties of a Component/Control in the property browser?
       56.2How to Reinitialize extender provider dependencies (the logic within CanExtend) from within the designer?
       56.3How do you detect the designer host getting loaded for the first time in your designer?
       56.4How do you provide "dynamic" default values?
       56.5How to debug your design time code (like designers, typeconverters, etc.)?
       56.6How do you make your custom data types property browser browsable when contained in a Control/Component (as a property)?
       56.7How to make properties in your custom data type appear in a particular order in the property browser?
       56.8How do I provide Intellisense support to my controls while coding against them and also provide Description support for the properties in the property grid?
       56.9How do I change the Zorder of my docked windows at design time?
       56.10How can I tell my form is being used in design time and not runtime?
       56.11How can I persist a collection of items into code?
       56.12How can I supply a list of values to be chosen from a dropdown list at runtime for a specific type similar to enums?
       56.13How to serialize properties of items that do not implement IComponent in a collection?
       56.14What is the function of TypeDescriptor?
       56.15What is the function of TypeConverters?
       56.16How do I make my custom dialog droppable in the design surface like a component?
       56.17How do I prevent my Component from becoming visible in the VS.Net Toolbox?

    57. Design Time Type Editors

      

       57.1In my UITypeEditor for a collection, how do I change the "(collection)" string to a string of my own?
       57.2How can I allow my user to add more than 1 type of object to my collection, during design-time?
       57.3How can I let the user edit my Multi-Dimensional collection?
       57.4What should I do to make my StringCollection property editable during design-time?
       57.5How do I make a class expandable within the property browser?
       57.6How can I paint a representation of enum values using a UITypeEditor?
       57.7From within a PropertyGrid, is there any way to display property names that differ from the actual class property names?

    58. Design Time UI

      

       58.1How do you prevent certain Controls from appearing in the property browser during designtime?
       58.2At designtime, how can I hide a base class property in my derived control from the user?
       58.3How do I make some properties not browsable in the designer, but browsable in the editor?
       58.4How do I prevent my Control's properties from getting combined with properties belonging to other objects in a Properties window?
       58.5How do I add a custom tab to the property grid when it is displaying my object's properties?

    59. VS.NET Debugging

      

       59.1How can I see debug/trace statements when I run my application in debug mode?
       59.2What is fuslogvw.exe?
       59.3How do I set the debugger to Break on Exception?
       59.4If I have a user control and a designer, how can I debug the designer?
       59.5How can I use the debugger paint and focus problems as the stops are always hit too early?
       59.6In a debug build, how do I write debug information to the output window (similar to the TRACE macro from VC6)?
       59.7Why am I getting duplicate trace messages for my trace statements?
       59.8How can I direct debug output to a text file?
       59.9Can I trace the Call Stack at any particular point without breaking into the debugger?
       59.10Can I trace the caught Exception without breaking into the debugger?
       59.11How do I conditionally include certain methods based on some preprocessor defines?

    60. VS.NET Macros

      

       60.1Can VB.NET code be formatted using macros?
       60.2Is it possible to call macros as part of a Visual Studio.NET command line build (or from a batch file)?

    61. VS.NET Tips

      

       61.1Is there any easy way to convert C# code to VB.NET?
       61.2Is there any easy way to convert VB.NET code to C#?
       61.3How can I word-wrap the Tooltip that is displayed?
       61.4How do I add a tooltip to my Button control?
       61.5How can I have a multiline tooltip?
       61.6How do I use VS to add an override for a virtual member of a baseclass?
       61.7Whenever I share files between projects it appears that Visual Studio.NET copies the files over into the new project. I want to just share the file and not have it copied over. Is there any way to do this?
       61.8How can I graphically set the tab order for controls on a form?
       61.9How can I speed up my work in Visual Studio?
       61.10I have code snippets that I use often. How can I manage them so I can easily used them?
       61.11In Visual Studio, all my docking windows are out of whack. How can I reset them so things will be docked properly?
       61.12How do I move a docked control around (or change the dock order) in my Form?
       61.13How can I instruct the compiler to use the Main method in Class2 instead of Class1?
       61.14If I create an assembly, how can I see the assembly/components from with the VS.Net "Add..." dialogs?
       61.15How does VS.Net find the referenced assemblies when I build a project from the command line?
       61.16How can I get the default namespace of a C# project in VS.NET?
       61.17How can I open a project created with Visual Studio .NET 2003 in Visual Studio .NET 2002?
       61.18In VS.NET, how can I change the build order of projects in my solution?
       61.19In VS.NET, how can I specify the start up project for my application?
       61.20Can I drag and drop code snippets using the VS.NET IDE?
       61.21How can I change the Word Wrap Property of VS.NET IDE?
       61.22How to convert an application project to class library project, and vice versa?
       61.23How do I start Visual Studio.NET from the command line?
       61.24What are the options with using Visual Studio.NET from the command line?
       61.25How do I create and use a component?
       61.26How do I compile unsafe code in VS.NET?

    62. Framework Tips Performance

      

       62.1Is it possible to cache an assembly to improve performance?
       62.2Why are .Net programs slow to load when running under a domain?

    63. Framework Tips Events

      

       63.1How do I intercept event subscription of a event in my base class?
       63.2How do I control the order in which events are fired to multiple subscribers?
       63.3How do I figure out if a particular client object has subscribed to one of my events?

    64. Framework Tips CGI

      

       64.1Can I write CGI applications using .NET?

    65. Framework Tips General

      

       65.1Is it possible to turn off strong name validation for an assembly?
       65.2How can I catch an exception on a program wide basis?
       65.3Can I generate UML diagrams from C# code?
       65.4Does .Net support "deprecation" as in Java?
       65.5Can .NET applications run on non Microsoft Platforms?
       65.6Can I play audio and video files using .NET?
       65.7Can I create file associations with .NET?
       65.8Is there any way to Shutdown/Restart Windows using .NET?
       65.9How can I Invoke a private interface implementations of an instance using reflection?
       65.10How can I adjust the version number for multiple projects without changing every AssemblyInfo.cs file constantly?
       65.11How do I launch IE or any other process from code?
       65.12How do I pre-JIT an assembly to native code during installation?
       65.13How do I get the install directory for the version of the runtime that is loaded in the current process?
       65.14How to retrieve the assembly version, name, etc. contained in the "AssemblyInfo.cs", from inside the running app?
       65.15Is there a way to access private and protected members of a class instance?
       65.16In VB.NET how do I access the runtime type object of a specified type from it's type name?
       65.17How do I print a document using .NET?

    66. Framework Tips General IO

      

       66.1How do you persist any object in the registry?
       66.2How can I listen to changes in a file/directory in the windows file system?
       66.3While deserializing how do I check whether a name is available in the deserialized info?
       66.4How come some of the objects are not initialized during deserialization?
       66.5How can I access a webpage from a windows form?
       66.6I just want to read a text file into a string. Is there some simple code for this?
       66.7I just want to write a simple text file. Is there some simple code for this?
       66.8I want to iterate through both files and folders in a given folder. Is this possible?
       66.9My application requires a simple ini file. Is there a easy way to implement this without using any parsing?
       66.10How can I convert a long path to a short path?

    67. Framework Tips Strings

      

       67.1How to I introduce culture information into formatted strings?
       67.2How do I convert a string to an double or int?
       67.3How can I convert the string "Red" into the color Color.Red, and vice versa?
       67.4Is there a .Net way of deciding whether a string is numeric or not?
       67.5How can I determine if a string is a valid date?
       67.6How can I convert an Enumeration member to string and vice-versa?
       67.7My program dynamically builds lots of strings. Is there a way to optimize string performance?
       67.8I hate string processing. Is there an easier way to do string manipulation?
       67.9How do I use the CSV clipboard format supported by Excel?
       67.10Is there a easy way to test Regular Expressions?

    68. Framework Tips Threading

      

       68.1Why do I have to use the STAThread attribute for my main method in my app.?
       68.2When I close my application, my secondary thread does not exit.
       68.3I call invoke Abort on my threads, but they still do not terminate.

    69. Framework Tips XML

      

       69.1How do I add an XmlNode from one XmlDocument to an XmlNode in another XmlDocument?

    70. Framework Tips 1.1

      

       70.1What's new in the 1.1 framework?
       70.2Is EnableVisualStyles method to support XP styles in my app broken?
       70.3How come I don't get to see the full call stack while debugging in VS2003?

    71. Framework Tips Math

      

       71.1Are there any libraries to do numerical analysis with .NET?

    72. Network Tips

      

       72.1How do I access an FTP server using .NET?
       72.2How do I send email using .NET?
       72.3How do I read email from a POP server using .NET?
       72.4I want to UUENCODE and decode data? Does the .NET framework have support for this?
       72.5Is there a way to Ping servers using .NET?
       72.6Is there a easy way to add Socks Proxy support?
       72.7Is there a easy way to query Whois information?

    © 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap