Click here to Skip to main content
15,886,799 members
Everything / Desktop Programming / Windows Forms

Windows Forms

WinForms

Great Reads

by Josh Smith
A task-oriented review of an animation library and the application which uses it
by Nish Nishant
This articles explains how to implement a TypeDescriptionProvider for a class to support multiple object types using a single class type
by Marc Clifton
Review your project dependencies.
by Nish Nishant
An ExifReader class in C# that supports custom formatting and extraction. StyleCop compliant code, with demos for WPF and Windows Forms.

Latest Articles

by Ralf Meier
The article walks through ShellySceneComponent and ShellyScenesComponent, which allow users to define scenes with multiple actions assigned to a control or controls for Shelly devices.
by Ralf Meier
This article is a continuation of a series on controlling Shelly® devices in a smart home. It introduces a component that works with standard controls without requiring adaptation.
by Graeme_Grant
.NET compliant Silent ClickOnce Update Background Worker Service for Winform, WPF & Console in C# & VB
by Mirnes Mrkaljevic
Make WinForms testable

All Articles

Sort by Title

Windows Forms 

7 Apr 2016 by The Zakies
Part 3 of a tutorial to show a graphics program using C# using GDI and SVG drag and drop and delete objects
20 Jun 2016 by The Zakies
we will build an outline line around the drawn lines so we would test the mouse click on this outline to know which line is selected. and we would in the coming update build a select function inside the move tool
24 Jun 2016 by The Zakies
in this tut we will create a technique to enable the user to control points within a drawn line, by drawing circles around points of the line , when the user clicks a circle he would control the corresponding point.
29 Jun 2016 by The Zakies
we would create Hand_tool to pan through the drawing form, and we would use a custom cursor of open and closed hands
3 Jul 2016 by The Zakies
we will continue the functionality of the hand tool with having a navigator panel which works as a map, we will also have a red rectangle which tells the user where he is actually viewing inside the whole form, also it can be moved to pan the form
7 Jun 2016 by The Zakies
[tut4] how to draw lines & to draw different types on end shapes like rectangle and circle using C#
20 Jun 2016 by The Zakies
Learn how to implement a tecnique of a parent form that createes and controls other forms , through the tecnique of using the tab control, also learn how to implement a menu for the tools, and how to add cutom cursor for each tool
11 Jan 2012 by agent154
A method to move rows within a DataTable
13 Jan 2012 by johannesnestler
Nice solution agent154, I'd just suggest to implement it as extension methods for data row: (and I don't liked your "error reporting" with the '0' Value - because '0' could be a valid index). But I have to say, even if you don't have a database behind the datatable you can use sorting (LINQ,...
2 Dec 2009 by bobishkindaguy
A simple entry box for various numbers, especially phone numbers.
9 Feb 2018 by Tony Zackin
A very simple yet customizable pop-up message box which auto-closes after a specified number of milliseconds.
9 Sep 2015 by Vladyslav Chernysh
The goal of this tip is to share knowledge and experience on ActiveX usage in .NET applications (back-end & front-end).
8 May 2011 by OriginalGriff
The Visual Studio Property pane is a control, which can be used in WinForms like any other, and it provides a simple, easy to use property editor for your classes. However, it is not obvious how to get it to open a browse dialog for a file path property.
7 Feb 2018 by Santosh Kokatnur
Adding Checkbox to a List View Column Header in C# WindowsForm application
7 Aug 2014 by PIEBALDconsult
This is an alternative for "Adding Functionality To .NET Controls"
17 Apr 2023 by OriginalGriff
How to add images to a Winforms Project so they are accessible as resources
22 Sep 2011 by Armando de la Torre
Use an error log control to validate forms.
29 Jun 2011 by Alexandros Pappas
Display of a context menu when pressing the Apps key in a DevExpress GridControl
14 Sep 2011 by #realJSOP
How to automatically display a Winforms menu when the mouse is hovered over an item
27 Apr 2012 by Igor Pashchuk, MBA
This is an alternative for "C# Pivot Table"
17 Sep 2018 by adriancs
A tool to backup & restore all MySQL databases in one click
5 Aug 2015 by sreeyush sudhakaran
VB.NET code for Base64 Encoding and Decoding of Image files
25 Mar 2015 by TarikHuber
Use STT (SQL Table Toolkit) to bind WinForm Controls to a DataGridview and to define ComboBox data sources
15 Mar 2015 by manchanx
Tidy, generic solution to bind Enums (with or without a DescriptionAttribute) to a ComboBox or other Controls
11 Sep 2015 by pgmr_64804
C# Gantt Chart For Winforms
5 Jul 2016 by _Matt_Wilkinson_
How to centralise a Form when using multiple screens
8 Jan 2010 by Harvey Saayman
Below is an example of changing the individual row colors based on one of the DataGridView's columns.While this is not hard to do, the property isn't always where you think it should be, its hidden within the rows DefaultCellStyle property.Here's the example:foreach (DataGridViewRow...
8 Jan 2010 by dwilliss
Another way to do something like this is to handle the RowPrePaint event and change the background there. The advantage to doing it this way is that if you have thousands of rows, you don't have to set it for every row at the beginning, which could take a few seconds. This way only sets it for...
4 Aug 2011 by Lakhan Aanjana
If cell color is depend on criteriaif (ca.con.State == ConnectionState.Closed) { ca.con.Open(); } string qry = "select * From productmaster "; SqlDataAdapter da = new SqlDataAdapter(qry, ca.con); DataSet ds1 =...
3 Oct 2011 by Manfred Rudolf Bihy
Using SendMessage and the PARAFORMAT structure, one can easily change the line spacing in a RichTextBox control
1 Dec 2014 by TarikHuber
Easy library for checking VAT Numbers of European Companies. Only usable with an German VAT for non German VAT!!!
24 Oct 2018 by Tecfield
Collapsible ListView
19 Nov 2015 by B.O.B.
A simple extension to add an item that has a data source bound to combobox.items
26 May 2014 by Serge Weinstock
A ComboBox whose suggestion list is based on loose character search
2 Dec 2012 by Bikash Karmokar
Connecting Windows Form Application With ADO.NET in C#
6 Oct 2012 by Frans Jan
This article shows how to save a Windows Form to a PDF file.
27 Nov 2017 by Altaf Ansari
Converting XML Data into DataTable and Exporting DataTable into Excel File
19 Feb 2011 by #realJSOP
Determine the number of unique colors in an image
19 Feb 2011 by a_pess
I think we may check if the color is repeated or not, any how this another alternative but in VB.NetPublic Shared Function GetImageColorsCount(ByVal bitmap As Bitmap) As Integer Dim ColorList As New System.Collections.Generic.List(Of Integer) Dim clr As Integer For...
20 Feb 2011 by Andrew Rissing
Just a few minor improvements to readability and such...The catch/throw isn't needed here, since you are just throwing it without doing anything in the catch block. A try/finally could have been used on its own.The try/finally isn't necessary because a using statement can achieve the same...
18 Sep 2012 by Raje_
This is a simple demo of how to display the number of unique products from a DataGridView.
6 May 2015 by Acharya Raja Sekhar
This tool helps a lot while capturing more number of snapshots. Example: Developers can use this tool to capture the UTR and save all snaps at the end to a Word document or save as individual images.
28 May 2015 by Robert.Verpalen
DataGridViewGrouper: add grouping functionality to the .NET DataGridView
16 Nov 2014 by Hassan Mokdad
This is a just a small tip to show a simple way of designing the user interface of Windows Forms for Desktops applications.
15 Jul 2011 by BillWoodruff
An interesting change in behavior in VS 2010 Pro ?
7 Jan 2012 by PIEBALDconsult
A binary search technique to determine which TabPage of a TabControl was clicked
3 Jan 2012 by Lutosław
This method, although it doesn't use binary search, handles Multiline tab pages too.private static intGetTabIndexAt( System.Windows.Forms.TabControl tabControl, System.Drawing.Point point){ int result = -1; if (tabControl != null) { for (int i = 0;...
24 Mar 2010 by mdanh2002
Depending on system preferences (in Control Panel/Sounds), the .NET WebBrowser control (just like Internet Explorer) may produce a click sound when changes are made programmatically to its DocumentText property, which is irritating to the user.There are two ways to avoid this:1. Use...
20 Dec 2011 by emolina
Public Sub DisableSound() Dim keyValue As String keyValue = "%SystemRoot%\Media\" If Environment.OSVersion.Version.Major = 5 AndAlso Environment.OSVersion.Version.Minor > 0 Then keyValue += "Windows XP Start.wav" ElseIf Environment.OSVersion.Version.Major = 6 Then ...
21 Dec 2011 by Member 8208766
To me the second method was problematic. After searching, I found an apparently equally good solution:webBrowser1.DocumentText = text;or in your case:webBrowser1.Document.Write("Hello, world!");from here:...
1 Mar 2012 by pipiscrew
nah, try the light one ://at FormLOAD WB.Navigate("about:blank"); //at treeview event private void treeview_AfterSelect(object sender, TreeViewEventArgs e) { WB.Document.Body.InnerHtml = (dR["html"].ToString()); }
2 Feb 2011 by #realJSOP
How to determine if your .Net app is running in the Visual Studio IDE
3 Feb 2011 by Alan N
I use the following to insert pauses into console apps when they are vs hosted. In fact it's the final lines in my standard template for a console app to ensure that the console stays visible until I dismiss it.if (AppDomain.CurrentDomain.FriendlyName.EndsWith("vshost.exe",...
8 Apr 2011 by intrueder
Extension method to make any WinForms control to be draggable at runtime
12 Jun 2010 by Kristian Sixhøj
A code snippet which makes a borderless form draggable.
12 Jun 2010 by Anshul R
The original snippet I made is in VB.NETProtected Overrides Sub WndProc(ByRef e As Message) MyBase.WndProc(e) If e.Msg = &H84 AndAlso e.Result = &H1 Then e.Result = &H2 End SubI used Reflector to translate it to C#protected override void WndProc(ref Message...
13 Jul 2010 by Dima Popov
A slightly different solution.using System.Runtime.InteropServices;private const int WM_NCLBUTTONDOWN = 0xA1;private const int HTCAPTION = 0x2;[DllImport("User32.dll")]private static extern bool ReleaseCapture();[DllImport("User32.dll")]private static extern int...
25 Aug 2015 by CharlieFoolsTheComputer
Constraining a form/dialog to a single monitor
27 Jun 2011 by charles henington
28 Jun 2011 by George Swan
Couldn't the class RegEdit be replaced by one simple method?private void SetKey(bool enableTaskManager) { using ( var mKey = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")) {...
18 Nov 2010 by ola halvorsen
When going from a multimonitor environment to a single monitor, windows get stuck on the other screens
22 Nov 2010 by Pat FitzHenry
If you have a window off-screen, type alt-space, and the letter m. Left click the mouse. Then continually press the left mouse key while scrolling the mouse around until the window comes into view. Click anywhere on screen off the window to drop the window. This should work for programs where...
30 Nov 2010 by MartinW1307
I have for years used the follow to fetch a window to a visible screen.1. Right click the window on the taskbar and select 'Move' (or use the keystrokes Alt-Space, M)2. Move the mouse a bit3. Press "left arrow"4. Move the mouse around - you will see the window outline ;) 5. left click...
6 Dec 2010 by Luc Schenkeveld
Alternate 3Right click on the taskbar and use "Show Windows Side by Side"
14 Aug 2013 by adriancs
A program/application for learning and writing HTML. Get instant visual effect side by side with your code as you type. Support HTML5, Javascript and CSS3 elements.
11 May 2015 by Yvan Rodrigues
A few lines of code to make using the Windows Forms RichTextBox easier to use as a logging window.
18 Jun 2011 by RakeshMeena
This extension can be used to update controls in a thread safe manner. This method requires a MethodInvoker delegate as input parameter. It just checks whether the control is on a different thread than the caller.
21 Jun 2011 by SergeyT2
You can use Action instead of MethodInvoker as well. And ".Invoke" at the method is unnesessary.public static void ThreadSafeCall(this Control control, Action method){ if (control.InvokeRequired) { control.Invoke(method); } else { method(); ...
19 Oct 2015 by charles922
Another way to implement Falling Blocks Game
7 Nov 2013 by MayurDighe
This tip describes how to fill the PDF Form Template programmatically
17 Jun 2014 by Vipul Bhatnagar
Create a multilingual application WPF
26 Oct 2016 by Midi_Mick
An edit control for the masked input of GUIDs
19 Dec 2010 by tumbledDown2earth
Hiding the form from alt-tab menu
19 Dec 2010 by meaningoflights
Tried it in VB.NET Winforms app, but no luck. It's still shown in the alt-tab menu:Protected Overrides ReadOnly Property CreateParams As System.Windows.Forms.CreateParams Get Dim cp As CreateParams = MyBase.CreateParams cp.ExStyle = cp.ExStyle Or &H80 ...
4 Feb 2010 by Gordon Kushner
Say you need capture an event for a control in a User Control and you are not permitted to change the control itself.You can hook into control events, even for private controls with this code://In a Windows Form//Get the private control cboSomePrivateControl from the user control's...
8 Dec 2009 by Your Display Name Here
How to use WebBrowser, a form, and an MDI parent to open Excel files
25 Jul 2017 by Sergi Ortiz Gomez
Quick tip for capture ENTER key in a Windows Form combobox
6 May 2012 by Shahin Khorshidnia
Tag is a useful property, but when you need more than a Tag, what will you plan for it?
10 May 2013 by youssef.obeid
This is to show you how to build a Dropdown button for Windows form
8 Apr 2015 by basilke7007
How to create rounded edge button (rounded corner button) in Winforms
4 Apr 2012 by CodeMajster
A detailed tutorial on how to embed multiple icons and color/animated cursors in VS2010 VB project assembly as native win32 resources.
13 Nov 2011 by KazMaxLtd
This article describes how to hide or show TabControl tabs at runtime
20 Nov 2011 by Bernhard Hiller
That's far too obscure.All you need to do is store a reference to the TabPage instance which was removed from the TabPages collection of the TabControl. You may use the form where the TabControl is placed for that purpose.You could also create your own TabControl which has an extra property...
6 Mar 2013 by zheng shuo
This tip shows how to share data between two or more forms in a Winforms application.
17 Feb 2010 by Alan N
Handling the Popup event raised by the System.Windows.Forms.ToolTip component would seem offer an ideal opportunity to alter the tooltip text to reflect an underlying change. Unfortunately the stack overflow caused by calling ToolTip.SetToolTip will soon put a stop to the attempt.The test...
17 Feb 2010 by William Winner
First, why would you want to change the ToolTip text during the PopUp? Why not hook the MouseHover of the control that you want to change the ToolTip? Dynamically setting the ToolTip does not require hooking the PopUp event.How about: public partial class Form1 : Form { ...
21 Aug 2011 by Armando de la Torre
How to activate a toolstrip button via a shortcut key
23 Aug 2011 by KenBonny
This is nice for non standard buttons (like a CTRL + s), but OK and Cancel buttons have standard implementations in a Windows Form. Look for the properties AcceptButton and CancelButton of a Windows Form (not sure if this applies in ASP.NET or WPF, I need confirmation on that). There you can...
3 Mar 2016 by The Zakies
Tutorial 2 (how to interactively add multiple shapes GDI using linked lists)
10 May 2015 by Peer Adi
This is a liquid container control for displaying liquid level in container or tank.
26 Apr 2012 by coffee_machine
A component to add localized strings to a Form's res'x.
8 Nov 2010 by TheDotNetGeek
Code snippet to make a control's text font style to bold dynamically at runtime in a windows application
25 Dec 2011 by Juan Davel
Managing Application Scoped Connection Strings
18 Feb 2011 by harbor
Manual Scroll Panel in a Panel or UserControl with AutoScroll=false
19 Dec 2010 by tumbledDown2earth
Trick for dragging the form while clicking on the client area
21 Mar 2011 by Nitin Singh India
People wonder how do delegates work and the threading issues associated with multicast ones.