Questions tagged [winforms]

WinForms is the informal name given to Windows Forms, a GUI class library in the Microsoft .NET Framework and Mono. Questions in this tag should also be tagged with the target framework ([.net] or [mono]) and should ordinarily be tagged with a programming language tag.

WinForms is the informal name given to Windows Forms, the graphical application programming interface (API) included as a part of Microsoft's .NET Framework, which provides access to the native Microsoft Windows interface elements by wrapping the existing in managed code.Wikipedia In addition to the Microsoft .NET Framework, a Windows Forms clone is available in Mono.

A Windows Forms application is an event-driven application supported by Microsoft's .NET Framework. Unlike a batch program, it spends most of its time simply waiting for the user to do something, such as fill in a text box or click a button.Wikipedia

Tag usage

  • Questions in this tag should also be tagged with the target framework - or .
  • Where a specific programming language is involved the language should also be tagged. Examples: ,
  • Some controls also have their own tags and if the question covers such a control in any substantive way adding the relevant additional tag is recommended. Examples: , .

Features

All visual elements in the Windows Forms class library derive from the Control class. This provides a minimal functionality of a user interface element such as location, size, color, font, text, as well as common events like click and drag/drop. The Control class also has docking support to let a control rearrange its position under its parent. The Microsoft Active Accessibility support in the Control class also helps impaired users to use Windows Forms better.

Besides providing access to native Windows controls like button, textbox, checkbox and listview, Windows Forms added its own controls for ActiveX hosting, layout arrangement, validation and rich data binding. Those controls are rendered using GDI+ (or libgdiplus for Mono WinForms).

Noticeably, Mono's WinForms clone is far from complete,

  1. Missing certain API.
  2. Bugs (in both libgdiplus and Mono WinForms) without fixes or workarounds.
  3. No backend for recent macOS releases (as macOS deprecated the 32 bit Carbon backend used by Mono WinForms).

MSDN Library

Comparisons with

Tutorials

98358 questions
1575
votes
47 answers

How do I update the GUI from another thread?

Which is the simplest way to update a Label from another Thread? I have a Form running on thread1, and from that I'm starting another thread (thread2). While thread2 is processing some files I would like to update a Label on the Form with the…
CruelIO
  • 18,196
  • 16
  • 40
  • 58
749
votes
35 answers

Implementing INotifyPropertyChanged - does a better way exist?

Microsoft should have implemented something snappy for INotifyPropertyChanged, like in the automatic properties, just specify {get; set; notify;} I think it makes a lot of sense to do it. Or are there any complications to do it? Can we ourselves…
P.K
  • 18,587
  • 11
  • 45
  • 51
672
votes
41 answers

How do I make a textbox that only accepts numbers?

I have a windows forms app with a textbox control that I want to only accept integer values. In the past I've done this kind of validation by overloading the KeyPress event and just removing characters which didn't fit the specification. I've looked…
Mykroft
  • 13,077
  • 13
  • 44
  • 72
670
votes
22 answers

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on

I have a scenario. (Windows Forms, C#, .NET) There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load method the UI become nonresponsive for the duration…
Prerak K
  • 10,940
  • 7
  • 30
  • 37
652
votes
14 answers

How can I save application settings in a Windows Forms application?

What I want to achieve is very simple: I have a Windows Forms (.NET 3.5) application that uses a path for reading information. This path can be modified by the user, by using the options form I provide. Now, I want to save the path value to a file…
Fueled
  • 8,776
  • 9
  • 29
  • 31
477
votes
8 answers

Replacing .NET WebBrowser control with a better browser, like Chrome?

Is there any relatively easy way to insert a modern browser into a .NET application? As far as I understand, the WebBrowser control is a wrapper for IE, which wouldn't be a problem except that it looks like it is a very old version of IE, with all…
Sylverdrag
  • 8,898
  • 5
  • 37
  • 54
441
votes
12 answers

How do I use OpenFileDialog to select a folder?

I was going to use the following project: https://github.com/scottwis/OpenFileOrFolderDialog However, there's a problem: it uses the GetOpenFileName function and OPENFILENAME structure. OPENFILENAME has the member named templateID, which is the…
Yun
  • 5,233
  • 4
  • 21
  • 38
433
votes
18 answers

How to remove all event handlers from an event

To create a new event handler on a control you can do this c.Click += new EventHandler(mainFormButton_Click); or this c.Click += mainFormButton_Click; and to remove an event handler you can do this c.Click -= mainFormButton_Click; But how do you…
Carrick
  • 4,423
  • 3
  • 18
  • 12
424
votes
11 answers

How do I create a message box with "Yes", "No" choices and a DialogResult?

I want to make simple Yes/No choiced MessageBox, but I think it is nonsense to design a form for that. I thought I could use MessageBox, add buttons, etc. to accomplish this. It is simple, but since there is no DialogResult returned, how do I…
Petr
  • 7,787
  • 14
  • 44
  • 53
358
votes
13 answers

How do I automatically scroll to the bottom of a multiline text box?

I have a textbox with the .Multiline property set to true. At regular intervals, I am adding new lines of text to it. I would like the textbox to automatically scroll to the bottom-most entry (the newest one) whenever a new line is added. How do…
GWLlosa
  • 23,995
  • 17
  • 79
  • 116
353
votes
9 answers

How do I group Windows Form radio buttons?

How can I group the radio buttons in Windows Form application (a lot like ASP.NET's radiobuttonlist!)? So I can switch between each case chosen from the options.
MW.
  • 3,549
  • 2
  • 16
  • 6
334
votes
13 answers

Get current folder path

I want to create a program that converts files. I would like the user to be able to place the executable file in any directory, and when executing that program (double-clicking on the .exe) I want the program to process all the files within the…
user2214609
  • 4,713
  • 9
  • 34
  • 41
312
votes
12 answers

How can I make the cursor turn to the wait cursor?

How can I display the Wait/Busy Cursor (usually the hourglass) to the user to let them know the program is doing something?
Malfist
  • 31,179
  • 61
  • 182
  • 269
310
votes
9 answers

Best way to implement keyboard shortcuts in a Windows Forms application?

I'm looking for a best way to implement common Windows keyboard shortcuts (for example Ctrl+F, Ctrl+N) in my Windows Forms application in C#. The application has a main form which hosts many child forms (one at a time). When a user hits Ctrl+F, I'd…
Rockcoder
  • 8,289
  • 3
  • 32
  • 41
290
votes
9 answers

Use of Application.DoEvents()

Can Application.DoEvents() be used in C#? Is this function a way to allow the GUI to catch up with the rest of the app, in much the same way that VB6's DoEvents does?
Craig Johnston
  • 7,467
  • 16
  • 40
  • 47
1
2 3
99 100