Click here to Skip to main content
15,885,985 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 Updated

Windows Forms 

N 24 Apr 2024 by M-Badger
Assuming that you wish to change which function is called for different joystick inputs based on a configuration file then you could use something like the code shown below. You might want to try a more elegant solution if there are a lot of...
N 23 Apr 2024 by sdecorme
HI, Actually I've made a winform application that read buttons and axis of my joystick. My goal is to have a config file to set input list with functions list. for example I'm using Sharpdx but I can change if needed Clear = buttons1 Left =...
N 23 Apr 2024 by M-Badger
I've not tested this but it would appear that the MS interop library version that you are using doesn't know how to convert images into MathML or LaTeX format. So either you need to convert them to MathML or LaTeX in the document before saving...
U 22 Apr 2024 by Ravi Bhavnani
After you set the Label controls' text, call Application.DoEvents();.� There's no need to call .Refresh() on the Label controls. Warning: The Form's message pump will respond to all events when executing Application.DoEvents();, including...
N 22 Apr 2024 by Avinash Korat
Here below is my code in which i try to update label controller which is directly placed inside a Form. I want it to be update after every single second. For that i suspend and resume the layout. But still it isn't updating any data on the...
U 22 Apr 2024 by Conduct dotnet
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the...
9 Apr 2024 by Pete O'Hanlon
So, what is it that you want to display as an image? The thumbnail that you would see in Windows Explorer? A detailed, scrollable view of the PDF? I'm going to assume that you want the user to actually see the PDF itself here. If this is the...
9 Apr 2024 by PhamLong301
I'm new in C# and I have create a scanner application by C# winform. Now I'm having a problem that when i use treeview for a folder and click in item inside (all items inside are images and pdf file). All image file format display normal in...
1 Apr 2024 by Member 15485980
I have a VB windows form app with a datagridview. I changed one of the column types to a combobox, which works ok. However, when I close out of the form I get multiple 'datagridview default error dialogue' complaining about system.index out of...
23 Mar 2024 by namphongjst
I make more time on it so it is solution, may be help someone : firt you get excel format by function public static string GetExcelCellFormat(string cellFormat )//= "G") { // MessageBox.Show("ok date !" + cellFormat); ...
13 Mar 2024 by krish88
I have created MSI Package using InstallShield@2014 supporting languages English - United States(1033) Chinese - Taiwan(1028) Chinese - China(2052) Language MST file (1033.mst, 1028.mst & 2052.mst) is embedded with MSI Package. My requirement is...
13 Mar 2024 by Dave Kreskowiak
Well, I'm going to tell you writing C# code to update the EULA is a waste of time. You're going to end up writing a ton of code to do a minute's worth of work in InstallShield. Learn to use the tools you have. Load the .MST/.MSI in...
12 Mar 2024 by Pete O'Hanlon
If you can download an old copy of the WiX installer, there was a utility called Dark that you could use to extract existing MSIs to C# classes. This has the ability to apply transformations so this might be useful for you as you would then be...
12 Mar 2024 by Graeme_Grant
I think that the best place to ask this question would be in the official help forum: InstallShield Forum | Revenera Community[^]
4 Mar 2024 by Richard MacCutchan
See your previous question on this same subject: No instance of overloaded function Microsoft::reporting::winforms::localreport::render[^].
4 Mar 2024 by Paramu1973
Hi, Iam using VS2015 Winforms, VC++. C++/CLI With my application I try to print the rdlc report. And I get the below error. can't take address of 'PrintRDLCReport::CreateStream' unless creating delegate instance. private: static Stream^...
3 Mar 2024 by Richard MacCutchan
According to LocalReport.Render Method (String, String, CreateStreamCallback, out Warning ) (Microsoft.Reporting.WinForms) | Microsoft Learn[^], warnings should be an array of Warning Class (Microsoft.Reporting.WinForms) | Microsoft Learn[^]...
3 Mar 2024 by Paramu1973
Hi, I have small application VS2015 Visual C++, WindowsForms. And I try to print the RDLC report directly to the printer. For that when I tried, I get struck, while I render the report. Any kind advices will be enable to complete the task. Thanks...
2 Mar 2024 by Pete O'Hanlon
Try e->graphics->FillRectangle(Brushes::White, e ->PageBounds.Left - Convert::ToInt32(e->PageSettings->HardMarginX), e->PageBounds.Top - Convert::ToInt32(e->PageSettings->HardMarginY), e->PageBounds.Width, e->PageBounds.Height); instead.
2 Mar 2024 by Paramu1973
Hi, I have a small program and Iam trying to print the RDLC report from the Button_Click(). While I convert the C# code to C++/CLI, I get struck from the below areas. Any kind helps ...Thanks // Handler for PrintPageEvents public: static...
29 Feb 2024 by OriginalGriff
We can't tell - we have no access to your code, especially not while it is running. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how...
27 Feb 2024 by OriginalGriff
Invoke is irrelevant: it is only required when you are using a thread other than the main GUI thread. Invoke "moves the code" back to the GUI thread so it is safe to access controls. If your colour doesn't change there are several possible...
27 Feb 2024 by Member 14771626
I have two button(read and write), each read and write has 5 textboxes. I want to compare the value between read and write, if it is match, the textbox will show color green else red color, but it didnt change the color when i reclick the read...
13 Feb 2024 by YDaoust
I have been using Visual Studio for ages, developing WinForms applications. Though this has always been irking, I am used to the fact that switching from the Code mode to the Designer mode often crashes the Designer, showing a call stack that is...
14 Jan 2024 by Code Artist
Consider this algorithm Implementation Downsampling Algorithm in MSChart Extension[^] to plot large data size without loosing details of trends and performance impact.
26 Dec 2023 by Christopher Rath
I've been struggling with this problem, off and on, for several months. Today, I decided to ask Bing Chat how to do this. I gave Bing the following direction: write c# code to extend the .net RichTextBox control in a WPF application so that...
13 Dec 2023 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.
6 Dec 2023 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.
22 Nov 2023 by RossMW
Its a bit hard to visualize what you are trying to achieve, but it sounds like you are trying to create your own version of forms modal operation. see the following link Form.Modal Property (System.Windows.Forms) | Microsoft Learn[^]
21 Nov 2023 by sanchita aggarwal
My problem is somehow related to https://stackoverflow.com/questions/34947504/how-to-show-a-pop-up-message-with-dark-background[^] What I have tried: but the main problem is I only have one form in my project and inside this one form only , i...
16 Nov 2023 by Member 16056976
Quote: When Maximized the Form gets cutoff on all edges by 9 Pixels... This isn't true, the form is overlapping the screen area by 9 pixels. I'm currently on the very same problem, where my not perfect solution is to set this.MaximizedBounds...
15 Nov 2023 by Andre Oosthuizen
You have 2 options to still use your control without enabling it in a web browser, both requires you to change your app to interact with the control though, not sure if this an available option to you - 1) In your Visual Studio project,...
15 Nov 2023 by theskiguy
I have been using the Adobe AXAcroPDFLib control in my VB.net WinForms apps for several years. It works pretty good most of the time, however, one of the biggest drawbacks is that each user had to enable the Adobe reader Addon in Internet...
15 Nov 2023 by Dave Kreskowiak
You cannot use the COM library anymore. Period. COM functionality in browsers was found to be a major security risk over a decade ago and the industry has been working on removing all support for it in the browsers. What you use in its place...
8 Nov 2023 by CHill60
Quote: That's exactly what i was waiting for . A nonsense comment. thanks Not really nonsense though is it? As Maciej says in his comment, it's "unfriendly to the UI" and Gerry says "without smashing the keyboard". At the very least it's...
6 Nov 2023 by rizla 2023
I'm not an expert, more precisely I'm learning C++. Can someone can help me with the code, I wrote the code but I get the error: "no instance of constructor "Spire::Pdf::Graphics::PdfSolidBrush::PdfSolidBrush" matches the argument leaf"...
6 Nov 2023 by Ankit Goel
I have a textbox and a datagridview with some results. I am looking for a way in which if the user is typing something in the textbox and in between, he uses his mouse and clicks on the datagridview, the focus should not leave the textbox means...
3 Nov 2023 by Mikael Anton Kurki
I have recently made a C# WinForm calculator project which fills a single 3x4 block of text boxes. Like so: private void calculate_Click(object sender, EventArgs e) { TextBox[][] textBoxOutputGroups = new[] { new [] {...
2 Nov 2023 by Maxim Kartavenkov
I think your code should be changed like this: for(int j = 1; j 1) { var3 = var3 + (((Math.Abs(7 - j) * (-1)) + 6) * tadd); } int WP = (j - 1) % 4; var S1 = Math.Pow((var2 - var1) * WP, 2); ...
1 Nov 2023 by Devendra Sarang
I want to achieve 2 functionalities as shown in the following pic: Want to achieve this At the top, there is a dropdown box and which contains values like 5, 10, 20, 50 and on changing it, it should display number of records in datagridview as...
31 Oct 2023 by M Imran Ansari
Implementing pagination in a DataGridView in a C# Windows Forms application involves managing the data source and updating the DataGridView's content accordingly. To implement the additional features you've mentioned, you'll need to modify the...
30 Oct 2023 by Rick York
You might find this article and the others in the series helpful : Doing UTF-8 in Windows[^]. I don't think you need to encode it per se. Won't just reading and saving text written in Cyrillic be sufficient?
30 Oct 2023 by Pete O'Hanlon
You should be able to use the capabilities of System::Text::Encoding to manage this. Have a look at the documentation Encoding Class (System.Text) | Microsoft Learn[^].
29 Oct 2023 by rizla 2023
I need to encode the text entered in the textbox in Cyrillic, something like this What I have tried: label->Text = u8 textbox->Text;
28 Oct 2023 by rizla 2023
Where am i wrong? When i select the paper size it doesn't change the size in the document pageSetupDialog1->PageSettings = gcnew System::Drawing::Printing::PageSettings; pageSetupDialog1->PrinterSettings = gcnew...
27 Oct 2023 by rizla 2023
I use printDocument and pageSetupDialog. How do I change the paper size when I select size from pageSetupDialog? What I have tried: private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {...
27 Oct 2023 by Dnyaneshwar Patil
I get the following exception while creating XmlSerializer object on some system, it's working as expected on others. Please provide suggestions or pointers. System.Runtime.InteropServices.COMException (0xD0000003): Exception from HRESULT:...
25 Oct 2023 by Richard MacCutchan
Use the properties of the PageSettings Class (System.Drawing.Printing) | Microsoft Learn[^].
24 Oct 2023 by Richard MacCutchan
I know nothing about Spire, but the error message suggests the constructor is asking for a PdfRGBColor object, rather than a reference. So try something like: Spire::Pdf::Graphics::PdfRGBColor color(0, 175, 178);...
12 Oct 2023 by Graeme_Grant
.NET compliant Silent ClickOnce Update Background Worker Service for Winform, WPF & Console in C# & VB
12 Oct 2023 by Member 13356291
I have five check boxes in a form and I have list of string. I want to check all check boxes if their text is found in this list of strings, then set check state to true. Notice: mylist is { Clients, Sales, Items } and panel1 has only five...
12 Oct 2023 by OriginalGriff
We can't help you - we have no access to your data, and it is very much crucial to how that code runs. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If...
6 Oct 2023 by Leona Ji Abengoza
I developed a C# .NET CRUD application through Visual Studio 2022. I would just like to know how can I setup an .exe file of it together with the database I created through xampp (MySQL). I have been working on this for weeks, but I can't seem to...
5 Oct 2023 by OriginalGriff
MySql is a server based DB system, and it requires an instance of MySql to be installed where the user can "get to it" - normally just somewhere on the same network segment. You can't just provide the app EXE and a DB file: the DB has to be...
14 Sep 2023 by Gokulnath007
How to create a circular gauge in C# Winforms like the attached images? What I have tried: I tried with Default Gauges given in CodeProject. It is not customizable for my requirement. https://i.postimg.cc/0r5GRXkk/Arc-With-Color.png...
28 Aug 2023 by Member 11164293
Add N char befor you quated stרingת for example insert into #tabname (f1) values (N'כן')
19 Aug 2023 by headshot9x
I have a class object and the Datagridview. I want to convert data in Datagridview to object, and can get/set values in object. Assume the quantity element in Datagridview equal to field of object, and variable name like the name first of...
19 Aug 2023 by OriginalGriff
Bear in mind that your processing is in a loop: so if your DGV has multiple persons, only the the last will be used - the earlier data will be discarded. You can't access _person in your button click handler: it is local to the GridviewToObject...
14 Aug 2023 by Dave Kreskowiak
How do you create the gauges? Well, you have the article that tells and shows you how. THAT'S HOW YOU MAKE THE GAUGES! We're not going to read it to you, do the work for you, nor can we understand it for you.
14 Aug 2023 by Graeme_Grant
Quote: I tried with Default Gauges given in Code Project. You have the source code, so you can modify it for your own needs. You just need to move the "green" from the inside to the outside. I would add a property to the control to select inside...
14 Aug 2023 by Richard MacCutchan
Plenty of examples to be found at circular gauge in C# - Google Search[^]
13 Aug 2023 by bhossain
Can any one help me how to recognise a dallas iButton, whether the button is present or not and read the data from the iButton, my requirement is to allow the user to login to the application if the IButton is present and valid, logout the user...
12 Aug 2023 by Graeme_Grant
Google search: C# dallas iButton[^] found this: GitHub - bjhindman/ownet: C# port of Maxim Integrated / Dallas Semiconductor's Java 1-Wire library for iButton devices and 1-Wire chips.[^]
6 Aug 2023 by Graeme_Grant
InvokeRequired (Microsoft Learn)[^] is only required if calling from another thread other than the main UI thread. So what you need to do is work out why the first time you're on a different thread and the second why you are on the main thread....
6 Aug 2023 by Bhavin Pokiya
I have created windows forms application with target framework 4.7.2. I am doing USB communication with device. I have 4 buttons on UI from which 2 button enable(connect and disconnect) and 2 disabled(download data and download log), when I click...
6 Aug 2023 by OriginalGriff
If you look at the Reference Source for Control.InvokeRequired:Reference Source[^] it shows you the code: public bool InvokeRequired { get { using (new MultithreadSafeCallScope()) { ...
5 Aug 2023 by Graeme_Grant
As @OriginalGriff points out, you can grind your system to a crawl. You could still use TPL[^] which uses a thread pool. It will manage the load for you based on the number of CPU cores. To do this, I would write the processing as a plugin DLL...
5 Aug 2023 by AlexandruCrisan
I want to be able to add hyperlinks (with placeholder text, not only the link itself being displayed) inside my RichTextBox. What I have tried: I tried by adding to the LinkLabel link = new LinkLabel(); link.Click += link_clicked; link.Text =...
5 Aug 2023 by Dave Kreskowiak
Well, you don't use a LinkLabel. That's only for a label control on a form and has nothing to do with the RichTextBox. All you do is set the DetectUrl property of the RichTextBox to true and add the URL string in the text as you would any other...
4 Aug 2023 by Shrikant_Yadav
Hi Team, I need to convert millions of image to a particular format using third party library. The library provide static functions to convert so I cant use multithreading or parallel.foreach because the library is processing one file at a time....
3 Aug 2023 by OriginalGriff
If the third party is using static methods, then a second Process environment is the simplest (and probably only) alternative - you can do it fairly easily using the Process class to activate an exe and it gets a separate environment even if the...
26 Jul 2023 by Graeme_Grant
To see what is happening, try capturing undandled exceptions: Application.ThreadException Event (System.Windows.Forms) | Microsoft Learn[^] Store to a file and raise as a MessageBox so that you can see what the error is.
26 Jul 2023 by LiterallyGutsFromBerserk
Hello everyone, I made a WinForms App using C#, and even created an installer for it. However, as soon as I double-click it from another user, it just wouldn't open. Can anyone please help? What I have tried: I tried changing the file paths in...
21 Jul 2023 by Mahfoud Bouabdallah 2022
In my Winforms application I am trying to use `SqlDependency` so I created this data access class: internal class DataAccessLayer { private readonly SqlConnection sqlconnection; public DataAccessLayer() { ...
21 Jul 2023 by Mahfoud Bouabdallah 2022
I made this change to the database ALTER AUTHORIZATION ON DATABASE::SIM TO sa; the previews owner (MYLIFE\MBoua) has (sysadmin and public) roles and windows authentication The (sa) has the same roles (sysadmin and public) with sql...
16 Jul 2023 by vincentkoert
Hello, Can anyone help me with the following? I want to make sure that the value I enter, remains in a datagridviewcombobox? The value I just entered is added to the list, but as soon as I select another cell, the value disappears. What I have...
15 Jul 2023 by satish212003
I want to auto filter the combobox list items automatically if anywhere the text is matches in the list items using c# in winforms. i.e If the user enter "Jonne" in the combobox, suggestions list must filter as follows. Jonne Mathew Kent...
15 Jul 2023 by Graeme_Grant
Here is a CodeProject article (Tip) that does what you want: ComboBox with Suggest Ability based on Substring-Search[^]
15 Jul 2023 by Graeme_Grant
You don't mention if you are working on a WPF or WinForms app, nor do you mention if you are using .Net 3.0+ or .Net Framework 4.5+, so I will assume it is a .Net Framework 4.5 WinForms app. You're using VB.Net, so I will do the same. You can...
13 Jul 2023 by Graeme_Grant
You wire it up here: if (onChangeEventHandler != null) { var sqlDependency = new SqlDependency(sqlCommand); sqlDependency.OnChange += onChangeEventHandler; } The issue I think is scope. The scope only exists in the if statement.
6 Jul 2023 by LiterallyGutsFromBerserk
I made a datagridview for a project of mine, which is displayed as in the picture below : https://i.stack.imgur.com/JAjAs.png[^] The columns on the left are generated from my database, while the ones on the right are added dynamically (they...
6 Jul 2023 by LiterallyGutsFromBerserk
I'm currently working on a project wheere, for each category and subcategory of my products, I need to do some inspections. Here's how my winforms works: 1.I click on the first combobox which indicates categories : ...
6 Jul 2023 by LiterallyGutsFromBerserk
Hello everyone, I am using the ClosedXML library in c# for my WinForms datagridview, and in my code, I added a bunch of columns dynamically. My issue is that those columns aren't exported afterwards to my excel(my guess is that it's not in the...
4 Jul 2023 by LiterallyGutsFromBerserk
As OriginalGriff said in their comment, the solution to this issue is to simply edit the formatting from the cellformatting method in order to avoid changes being overridden. In my own case, I declared an global integer "numColsGen"(number of...
26 Jun 2023 by OriginalGriff
First off, never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead. When you concatenate strings,...
23 Jun 2023 by Graeme_Grant
Recommended method of doing work from C# was given here: Export datagridview to excel while keeping the formatting[^]: 1. Create a Macro recording of the actions that you wish to perform 2. View the VBA code generated for you 3. Use the VBA code...
21 Jun 2023 by LiterallyGutsFromBerserk
I managed to find a solution with a PaintCell override : private void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex == 1) { ...
21 Jun 2023 by LiterallyGutsFromBerserk
I have a datagridview that's already bound to a database. For each row in my datagridview, it shows a minimal, avg/nominal and maximum value. However, I'd like it if there is only one value that I give it, to merge cells into one cell, just like...
21 Jun 2023 by OriginalGriff
This is the same question you pasted this morning: Change a single cell's border style in datagridview[^]
21 Jun 2023 by Graeme_Grant
Google search is your friend: winform datagridview merge cells - Google Search[^] First search result: How to Merge DataGridView Cell in Winforms - StackOverflow[^] The default control is limited in what it can do. You will need to use a...
20 Jun 2023 by LiterallyGutsFromBerserk
Hello everyone, I have a datagridview with three columns where, everytime I only have one value, I want to merge my columns, similarly to the picture below : enter image description here I have made sure to have my three column values for each...
20 Jun 2023 by OriginalGriff
See here: How to Merge Cells in DataGridView | 10Tec[^] And do yourself two favours: 1) Indent your code! It's a whole load more readable for everybody if you do, and VS will auto indent it to your preferred style for you. 2) Don't swallow...
19 Jun 2023 by Graeme_Grant
When having issues like these, it is always a good idea to create a test project and check what is happening. Excel Interop - Microsoft Learn[^] especially. So, I have created a spreadsheet manually and put a numeric value in a cell. Then I...
19 Jun 2023 by LiterallyGutsFromBerserk
I am making a Winform application where I export my datagridview to excel. However, when I do it, it doesn't retain the formatting,despite the existence of a line to do so. Here is my code : string fileName; SaveFileDialog saveFileDialog1...
19 Jun 2023 by Member 16032850
so I want to make a winform app that scans a barcode and a countdown of 2h starts once the barecode is scanned any help? What I have tried: this my first time working with barcode so I don't know what to do
19 Jun 2023 by OriginalGriff
Most barcode readers come preconfigured to act as a keyboard: you scan the code and to your app it looks exactly like the user typed the number in. That's probably not helpful to you! However, most scanners can also be configured to provide...