Click here to Skip to main content
15,880,651 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 Score

Windows Forms 

4 Jul 2014 by Chakravarthi Elchuri
How to use WIA supported scanner using C#
28 Nov 2011 by Akos Orban
Set Owner of a WPF Window to a Form
26 Aug 2012 by Wendelius
The tip shows one way to resolve if a user control is in design mode.
5 Jul 2013 by Johnny J.
A sample owner-drawn ComboBox
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.
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
19 Feb 2011 by #realJSOP
Determine the number of unique colors in an image
28 Apr 2010 by Keith Barrow
If you have a Winforms application that auto loads data, there is no doubt that you’ll have come across the problem of data loading at design time (i.e. when opening the code in the designer). At best, this slows the designer down, at worst it might crash VS and prevent the control from...
26 Jan 2011 by #realJSOP
When you need to communicate with the app that contains your ServiceHost object, use custom events
27 Jun 2011 by charles henington
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 wmjordan
Rendering text with OpenType fonts by P/Invoking GDI API in WinForm applications.
17 Aug 2013 by adriancs
An Office 2010 Style Color Picker for .NET WinForm.
3 Jan 2012 by PIEBALDconsult
Getting the line and position of the cursor in a TextBox
17 Apr 2023 by OriginalGriff
How to add images to a Winforms Project so they are accessible as resources
6 Jul 2011 by Brian C Hart
This tip shows how to add support for New Horizontal Tab Group and New Vertical Tab Group commands to the Window menu of an application using the DockPanel Suite by Weifen Luo, and some other minor improvements to help decided if at least one of your windows is docked to the side of the main form an
25 Mar 2015 by TarikHuber
Use STT (SQL Table Toolkit) to bind WinForm Controls to a DataGridview and to define ComboBox data sources
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).
11 Jan 2022 by Jo_vb.net
My idea was to host a WPF user control with Ribbon within a WinForm VB.NET project and try to use MVVM pattern.
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...
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...
15 Jul 2011 by Simon Bridge
Full code listing for a very simple but effective Colour-Combo (Color for those in America)
25 Dec 2011 by Juan Davel
Managing Application Scoped Connection Strings
30 Jan 2012 by leppie
Here is yet another alternative (originally from http://xacc.wordpress.com/2009/03/05/tree-traversal-extension-methods/[^]):public static class TreeExtensions{ public static IEnumerable TraverseDepthFirst( this T t, Func valueselect, Func
26 Apr 2012 by coffee_machine
A component to add localized strings to a Form's res'x.
14 Oct 2015 by cwfong
Make these controls read-only on WinForm
18 Feb 2010 by Ron Beyer
If you are designing in a WinForms component, which is anything that derives from Control at some point (Forms, UserControls, panels, etc), then you can use the following code:if (this.Site.DesignMode) //Do stuff[edit]The above will throw an exception if Site is not set (in...
12 Apr 2011 by KevinPorter
How about using a Mutex? This should also work for Terminal Services sessions. Use in Program.csstatic Mutex mut;try{ bool isOwned = false; mut = new Mutex(true, Application.ProductName + " MUTEX: {53A4988C-F91F-4054-9076-220AC5EC03F3}", out isOwned); if (!isOwned)...
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(); ...
7 Jan 2012 by PIEBALDconsult
A binary search technique to determine which TabPage of a TabControl was clicked
22 Nov 2011 by #realJSOP
Allow any number of forms to be used as a main form with easy transitions between forms
25 Dec 2011 by PIEBALDconsult
OK, here's another way (I found this at http://dotnet.mvps.org/dotnet/faqs/?id=textboxcaretpos&lang=en[^]). [System.Runtime.InteropServices.StructLayoutAttribute (System.Runtime.InteropServices.LayoutKind.Sequential)]private struct ApiXY{ public int X ; public int Y ;}[ ...
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:...
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;...
3 Feb 2012 by Member 147785
Hello!Here is a small article - Show progress on long-running operations, which describes approach to keep the UI responsive, starting long-running operations in separate thread. This approach is native and without any 3d-party libraries and even without BackgroundWorker.For example, the...
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
8 Dec 2009 by Your Display Name Here
How to use WebBrowser, a form, and an MDI parent to open Excel files
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"
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...
21 Mar 2011 by Nitin Singh India
People wonder how do delegates work and the threading issues associated with multicast ones.
29 Jun 2011 by Alexandros Pappas
Display of a context menu when pressing the Apps key in a DevExpress GridControl
22 Sep 2011 by Armando de la Torre
Use an error log control to validate forms.
2 Oct 2011 by Anshul R
You can use BackgroundWorker to do the work and report the progress using:private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e){ this.progressBar1.Value = e.ProgressPercentage;}
28 Sep 2011 by Vladimir Vorobiev
This example contains the code to manage the menu of open forms (standard Windows menu). When created, each mdi-child gets a menu item and event handler through which this element is removed from the menu when the corresponding form is closed.private void ShowOrCreateMdiChild(Type formType)...
1 Oct 2011 by Rafał Klepacz
private void OpenForm() where T : Form, new(){ T frm = (T)new List(this.MdiChildren).Find(f => f is T) ?? new T() { MdiParent = this }; frm.Show(); frm.Focus();}and usageOpenForm();
7 Oct 2011 by Bruce Lee Harrison
The background method is probably the most preferred method, but I've found this one is very easy to implement, and it's just one short line:BeginInvoke(new Action(() => progressBar1.Increment(1)));Place this in your worker thread to report to the UI. Not sure how "good" this is, but it...
3 Feb 2012 by Sagotharan Jagadeeswaran
Thanks, I am just changing False to True, And I got Automatically Check TreeView Child Nodes When Parent Is Checked.private void treeView1_AfterCheck(object sender, TreeViewEventArgs e) { if (e.Node.Checked) { ...
14 Mar 2012 by R.Tarik
Print you PDF silently using C#
25 Aug 2015 by CharlieFoolsTheComputer
Constraining a form/dialog to a single monitor
8 Apr 2011 by intrueder
Extension method to make any WinForms control to be draggable at runtime
2 Feb 2011 by #realJSOP
How to determine if your .Net app is running in the Visual Studio IDE
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?
6 Apr 2013 by Thomas Daniels
A tip about how to set the position of a Windows Forms MessageBox in C#
23 Sep 2016 by Midi_Mick
This is an alternative for "Resolve DesignMode for a user control"
28 May 2015 by Robert.Verpalen
DataGridViewGrouper: add grouping functionality to the .NET DataGridView
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 May 2015 by Yvan Rodrigues
A few lines of code to make using the Windows Forms RichTextBox easier to use as a logging window.
12 Jun 2010 by Kristian Sixhøj
A code snippet which makes a borderless form draggable.
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.
7 Feb 2018 by Santosh Kokatnur
Adding Checkbox to a List View Column Header in C# WindowsForm application
6 Nov 2011 by RaviRanjanKr
Yet another way to this is as follows: using System;using System.Collections.Generic;using System.Windows.Forms;using System.Threading;namespace OnlyOneInstance{ static class Program { [STAThread] static void Main() { bool...
25 Mar 2011 by FDW
Maybe this is helpful, it tries to switch to the first running instance:namespace UltraSimple.Win{ static class Program { [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd); [STAThread] ...
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...
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"
4 Feb 2012 by springy76
By using a LinkedList, you can even mimic true recursive behavior without using recursive calls; the order will be "0,3,9,10,4,1,5,11,12,2,6,7,8", then:public static IEnumerable GetRecursive(this IEnumerable source, Func> subSelector){ var...
24 Jan 2011 by Nejimon CR
Make irregular splash screens without writing a single line of code!
22 Nov 2011 by #realJSOP
A useful technique that could be used for winform apps which require a login dialog
26 Oct 2016 by Midi_Mick
An edit control for the masked input of GUIDs
11 Jan 2012 by agent154
A method to move rows within a DataTable
22 Dec 2010 by Vercas
Unfocusable, borderless form, perfect for floating controls!
25 Nov 2013 by selvaprakash.s
This tip will demonstrate how cookies are passed from one control to another control in C# .NET in authenticated webpage.
18 Sep 2012 by Raje_
This is a simple demo of how to display the number of unique products from a DataGridView.
7 Nov 2013 by MayurDighe
This tip describes how to fill the PDF Form Template programmatically
6 Oct 2012 by Frans Jan
This article shows how to save a Windows Form to a PDF file.
2 Dec 2012 by Bikash Karmokar
Connecting Windows Form Application With ADO.NET in C#
10 May 2013 by youssef.obeid
This is to show you how to build a Dropdown button for Windows form
8 Apr 2012 by Sreedeep.S
Serial Communication with the .NET Framework in Winforms
19 Dec 2010 by tumbledDown2earth
Hiding the form from alt-tab menu
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 ...
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.
3 Oct 2011 by Manfred Rudolf Bihy
Using SendMessage and the PARAFORMAT structure, one can easily change the line spacing in a RichTextBox control
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.
8 Mar 2011 by Ron Levy
WebCam Application with Scheduling
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",...
26 May 2014 by Serge Weinstock
A ComboBox whose suggestion list is based on loose character search
14 Jun 2014 by Graham Wilson
A method of ensuring that SplitterContainer controls with fixed panels are properly resized when AutoScaleMode is ScaleMode.DPI
24 Jan 2012 by intrueder
Extension method to make it easy to retrieve all nodes of a TreeView control.
24 Oct 2018 by Tecfield
Collapsible ListView
7 Jun 2016 by The Zakies
[tut4] how to draw lines & to draw different types on end shapes like rectangle and circle using C#
18 Dec 2013 by Nanda Kumar Chintam
Demonstration of Excel manipulations using C#
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
17 Jun 2014 by Vipul Bhatnagar
Create a multilingual application WPF
9 Feb 2018 by Tony Zackin
A very simple yet customizable pop-up message box which auto-closes after a specified number of milliseconds.
6 Mar 2014 by Jacky Yiu
Visual cryptography is a cryptographic technique which allows visual information (pictures, text, etc.) to be encrypted in such a way that the decryption can be performed by the human visual system, without the aid of computers.
11 Sep 2015 by pgmr_64804
C# Gantt Chart For Winforms
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.
15 Jul 2011 by BillWoodruff
An interesting change in behavior in VS 2010 Pro ?