Click here to Skip to main content
15,884,425 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 

6 Jan 2014 by JayantaChatterjee
Hi all,I create a form which have some function perform on the form_load, at the meantime I want to show a form(like "please wait").I used Background Worker. My code is :-private void QuestionForm_Load(object sender, EventArgs e) { WP = new WorkerProgress();//here...
7 Jan 2014 by OriginalGriff
You cannot access controls exactly from the thread that they were created on: the UI thread.You are trying to access them from your BackgroundWorker, which is a different thread entirely.Either use the Invoke method to access them, or move the code into the UI thread via the...
7 Jan 2014 by Rahul VB
Hello Mam, When ever we start a form based application, the application starts on a single UI thread. Now if i perform some operation using some of its controls. Suppose, on button click, perform some calculation. If the calculation is small its okay, but as the work to be done grows,...
10 Jan 2014 by Rahul VB
Hello Mam, look at the code below: class Class1 { static TableLayoutPanel tlp; public Class1(TableLayoutPanel TLP) { tlp = TLP; } public void doWork(object sender,DoWorkEventArgs e) { ////perform...
11 Jan 2014 by Alan N
Hi Jayanta,I was reading the discussion you were having with OriginalGriff and I wonder if the real problem is the poor performance of Microsoft's TableLayoutPanel. If you are having issues with redraw then enabling double buffering on the control will speed it up. I have found that on .NET...
23 Aug 2014 by junaid2
i have created an application in which i have designed a crystal report and the application has single winform in which there is a crystal report viewer. everything is fine and working but when i try to run that same application on other PC an error occurs saying "crystal report application name...
23 Aug 2014 by OriginalGriff
This isn't a problem we can solve, or even help with that much: we don't have access to your code or to the "other PC".The chances are that when you try to run the app on a different PC, one or more of the assemblies, resources or frameworks that your app requires is not installed, and so it...
2 Sep 2013 by Manish Arya
Dear All, private void btnSave_Click(object sender, EventArgs e) { string connstr = @"Server=.\SQLEXPRESS ;Initial Catalog=RPSJDB;Integrated Security=True; Max Pool Size=100"; SqlDataReader reader = null; SqlConnection conn = null; ...
2 Sep 2013 by saguptamca
You must check mobile number value before inserting into database(because it's numeric datatype in your db).Check whether its null or not, it is then handle situation by writing different queries.
20 Sep 2022 by Mateen Khan
I have a winforms application which was working fine. Recently i formatted my system and reinstalled VS 2008. From that time the application has stopped running.When i run it through VS it gives error"exception has been thrown by the target of an invocation."I went on to debug and...
15 Mar 2012 by Mateen Khan
Eventually I solved this myself. It was just a matter of getting to the root of the problem.Actually the cuase of this exception was another exception which occured inside the method being invoked.So i went to look out for solution by searching the exception ex.innerexception .From there...
5 Jun 2012 by Nilesh (Puna)
Disable the ajax for a moment (EnablePartialRendering="false" on the scriptmanager).we Got Exception aftr that delete EnablePartialRendering property.
21 Dec 2012 by Elegantly Wasted
Great said by Mateen Khan, you need to understand what is you controls default value..eg i'm using combobox in silverlight and i was trying to bind its selected indexas a default its selected index was -1but it was get nothing from the respective property ...I looked inside...
20 Sep 2022 by Member 15773989
for the said error, we are talking about inner exception. How to get this inner exception? running bat "${NUGET_HOME}/nuget.exe restore Dotsolution.sln from jenkins file and getting this error: Error parsing solution file at...
4 Nov 2022 by Member 14623639
I know this is a common question people ask but for days I have been researching and couldn't find a way that will help me. I'm developing a screen sharing program and using TCP to send the desktop screenshots over the networkstream. I tried...
4 Nov 2022 by RickZeeland
Try this CodeProject article: Windows Remote Desktop Application[^] It probably has TCP routines you can use.
4 Nov 2022 by Chris Copeland
In addition to RickZeeland's comment, another important thing to remember when it comes to network/streaming is that there's no guarantee how many bytes you'll receive at any given time. byte[] bytes = new byte[1000000]; ...
16 Nov 2010 by Klemzi
Hi,I am having a big problem with my custom editor for my component and I can't find solution. "Select Resource" dialog is the default window for editing "image types" (type "Image" for example) in Visual Studio. For example, we have a component called "MyComponent" with property...
4 Sep 2012 by Flux89
Hello guys,when trying to display a bar chart with loooots of bars, the screen space is not enough. However, this wouldnt matter too much If I could at least save the image with a much higher resolution AND more details in it.So far I managed to save the image with a bigger size via:...
11 Aug 2020 by Member 14898617
i am building a win form app using access database as data-source , and in the search button of my winform i have this code" private void searchAccessDatabase() { if (string.IsNullOrEmpty(KeywordTextBox.Text.Trim())) ...
11 Aug 2020 by Sandeep Mewara
Think, this should not be in single quotes: 'System.String' Further, can you make sure the strFilter looks like as expected? Surely following corrections: 1. Is it not missing spaces between all the OR conditions? 2. Missing OR in line: ...
26 Jan 2011 by OrlandoCurioso
Customize an internal designer by encapsulation in a custom component designer
13 Apr 2020 by Member 14132181
I am getting issue while tab reach to next new row after loading data from data base to datagridview. Can anyone correct my code?? What I have tried: private void dataGridSALEITEM_CellValueChanged(object sender, DataGridViewCellEventArgs e) ...
13 Apr 2020 by RickZeeland
You could try this: foreach (DataGridViewRow row in dataGridSALEITEM.Rows) { if (row != null) { ... your code } } If you still get errors, you should test the other values for null. Also try stepping through your code after setting a...
13 Apr 2020 by OriginalGriff
It's going to depend on the data - which we have no access to - which part of that code is wrong, or your DB design needs improvement. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out...
29 Aug 2012 by Code Artist
(AGauge) WinForms Gauge control
7 Feb 2017 by Richard MacCutchan
You already posted this question at (C#) How to make this kind of design and functions - C# Discussion Boards[^]. Please do not repost in multiple forums.
6 May 2021 by Flidrip
Hello! Hopefully, someone can set me on the right track, I am officially confused... I have two forms (form1) and (form2), in form1, I have a DataGridVied, named dgvLøyvehaver. When I double click on a row in the DataGridView, it opens up form2...
6 May 2021 by OriginalGriff
First off, don't do it like that! 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...
26 Nov 2012 by sumans4324
Hello All,Greetings for the day..!I have a gridview(winform) bound to "obect data source(nhibernate object)" with "Aut-generate cols" true, which I use only to display & filter the data. Now the inner object(or master object's is not displayed). I know pretty well that all the objects...
5 Sep 2014 by Member 10960577
plz can any one help am new to crystal report plz help me urgent.. thank you all
24 Nov 2009 by Dan Neely
I have some bitmap images being displayed in a DataGridView's and on custom controls.  These are all basic lineart type images not pictures.  I recently noticed that they all looked slightly faded/washed out and when I examined screenshots I took I discovered that any color channels that should have
23 Nov 2009 by Christian Graus
What format do you use ? jpeg is lossy, and the colors in a JPEG will change.
24 Nov 2009 by Dan Neely
I ended up tossing the image stream and getting the images from the Resources.resx file instead.  Slightly more work; but this means that the images will always be accessed from the originals in source control and that any changes to the images will be automatically included in the next build.
24 Apr 2013 by Bart de Lange
Hello All,I'm making a web browser with the default browser control of visual studio 2012.but i want to make a custom login popup when a website is trying to loginwith a .htpasswd file(this usually happens if you try to access you're router website or such sites)my problem is: I...
24 Apr 2013 by Sergey Alexandrovich Kryukov
Please see my last comment to the question, about HTTP response and HTTP request. You can do it directly using the class System.Net.HttpWebRequest:http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^].It might help you to understand what's going on, but I doubt it...
9 Apr 2013 by suraj bhakta01
I have created a window form for login, where user can login with an id and password. After authentication the user can move to the Select_Company form. From there the user select the company and branch and moves to transaction window form.On initial login the user properly logged in and...
9 Apr 2013 by V.
Honestly, I think you need to redesign your application, you're not using different layers and are creating database connection all over the place. I propose you redesign to a DAL - BL - GUI layered approach before addressing any further problems. in The Business Layer (BL) you can then keep a...
9 Apr 2013 by _Maxxx_
The codefrmLogin Login = new frmLogin(); Login.ShowDialog(); if (Login.pAccept) { frmSelectCompany SelectCompany = new frmSelectCompany(); ...
19 Jul 2013 by siva@attur12
We have C#.Net windows application and i need to know how to get the memory consumption details of my application. I already tried System.Diagnostics.Process to get the current process memory information. I need to know how many objects are in memory and also memory consumption details for each...
19 Jul 2013 by Zoltán Zörgő
Look around here: http://msdn.microsoft.com/en-us/library/w8f5kw2e(v=vs.100).aspx[^]
27 Oct 2007 by carlos@takeapps
A basic .NET file browser fully based on the framework
6 Sep 2011 by akremb22
I got a project to complete some tasks on it, but when I try debug I have this error inDbProviderFactory Dbfactory = bProviderFactories.GetFactory(MasterConnectionProvider);With my MasterConnectionProvider is System.Data.SqlServerCe.EntityUnable to find the requested .Net Framework...
6 Sep 2011 by Wendelius
Have you referenced both system.data.sqlserverce.dll and System.Data.SqlServerCe.Entity.dll?
7 Oct 2005 by Fred Wang
An article on resolving the issue of unintentional web form resubmission.
25 Jan 2012 by mohammadghaderian.bp
HiI want protect my software with serial activation process.Can you help me product or one way that do this process for me ?thanks a lot your answer
25 Jan 2012 by Michel [mjbohn]
Have a look at this CP article:Application Trial Maker[^]regards Michel
9 Apr 2009 by SprinterDave
A native .NET library and application to view the PNGs embedded in a MNG
2 Dec 2008 by Cirilo Meggiolaro
Multicast delegates provide functionality to execute more than one method.
16 Jan 2012 by Simon Bridge
Multiple-file, searchable, streaming compression library implemented natively in .NET.
26 Jul 2011 by Nitin_Verma
Hi All,I have a winform app in VS - 2008, It is client server based application using .net remoting 2.0.On My server I have a Method which would be called from client.Now in this method, I want to update value of Datagrid in one of my winform. Here I am getting an error:"An error...
27 Jul 2011 by Shameel
.NET requires that you make your apps STA to be able to use ActiveX controls. Mark your main method with the [STAThread] attribute.
27 Jul 2011 by Sergey Alexandrovich Kryukov
Shameel recommended you to use [STAThread]. This is not always possible, as your application might require [MTAThread]. In this case, here is what you can do: create a separate thread and set its apartment state to System.Threading.ApartmentState.STA using...
27 Aug 2012 by Kumar, Ravikant
A .NET resource (.resx file) translator. English to any other language.
13 Jul 2008 by Rajneesh Noonia
The source code / article published here is to provide features of MS Script control (Functions like AddObject) and some features of VSA/Visual Studio editor like intellisence, code completion etc
3 Aug 2005 by Sautin.net
12 Oct 2023 by Graeme_Grant
.NET compliant Silent ClickOnce Update Background Worker Service for Winform, WPF & Console in C# & VB
19 Apr 2012 by Jani Giannoudis
Concepts and patterns for the handling of strings in multilingual applications.
17 Nov 2010 by PavPS
.NET C# TrayBalloon component with hyper-links and fading.
20 Jan 2005 by SuperJason2k
A .NET DLL and sample application that interfaces with UPS's XML API to retrieve tracking information. You can also use it to generate an RSS feed..
2 Dec 2010 by sudjp
Hi,I have a strange problem with the .Net WebBrowser control. I'm trying to delete facebook cookies and then dispose the WebBrowser control so that the cookies might be released from the memory and then reinitialize the WebBrowser control again in order for them to relogin to...
20 Jan 2011 by fjdiewornncalwe
For starters, try seeing if you are getting exceptions when deleting the files. My guess is that you may be experiencing this.
24 Dec 2012 by sherlock chou
Hello,I have a problem about msg loop in .net winform. as we know,each ui thread at least needs one msg loop.but i have tested the code below,i thought the form "frm" would spash and disappear,but it worked well except the client area,i can use mouse to move the form,to close the form etc. now...
15 Sep 2020 by jugs0101
Ok, I have a problem, and I'm not expecting an answer straight off. I need some help, bouncing ideas if anyone can spare the time. I find that talking about things like this can help come to a solution quicker, but I'm stuck for someone to talk to about it! I have a .Net 2.0 Winforms program...
19 Apr 2013 by hadeed1472
Hi Expertsi have to design a report which ll print fee vouchers for all specified students. Now by which way i should design report that a single page contain 3 copies of same voucher (student,bank and college copy). what should i use a rectangle , table or any thing else? and how it ll...
7 Dec 2012 by Killzone DeathMan
Hi,My question is simple, I have created a program, but when there has been 10 minutes of inactivity, the application will Close, like this: Application.Close();I already search about Mouse Move event and there come some errors, in my Form1.Designer.cs is an error in this line:...
7 Dec 2012 by Zoltán Zörgő
Please clarify: you want to close you app after the timeout, or it is closing as a bug, and you want to avoid this? In the first case, you could consult this article: Application Idle[^], in the later case, you should post a little more of your code.
7 Dec 2012 by Sergey Alexandrovich Kryukov
This is how to do it:this.MouseMove += (sender, eventArgs) => { // actual parameter types are inferred by a compiler from the known event type // from here, call whatever you want, using eventArgs parameters};You can do the same using anonymous method even if you work with C# v.2...
10 Nov 2016 by Mehedi Shams
Coding a simple magic with cards!
8 Oct 2009 by Anthony Mushrow
Create and edit 2D maps using tiles
5 Nov 2013 by Ziee-M
Hi all,i have an application that checks for update from a website, if the website version is newer , it erase the current .exe and replace it with the .exe in the website.In the case of one layer application, i am pretty sure its good enought!Now, the application is multi layers...
5 Nov 2013 by Bhuvanesh Mohankumar
Hi Ziee-M,You first list out what all the Files will be replaced when its a Single Layer Application.IF the Application is Single layer or Multilayer, the Logic Layer & Data Layer are refereced to the third layer UI for sure.As the other 2 layers are reference all the Final DLL will...
5 Nov 2013 by expert-programmer
I think It will be best if you create two exe. 1 for update checker and downloader and another one is your application. That you don't fetching up with any problem. first application update checker find new update exe and download it silently and replace your application.
15 Mar 2015 by Member 11520771
so I'm making this project in Windows forms (Visual Studio 2013, C#). Which method would you recommend for adding a feature which would allow players to move freely between turns?I am stuck at the part where some other button (than the X/O-able) is supposed to go one turn back. Said button...
15 Mar 2015 by HKHerron
OK, If I understand the question correctly, you are basically wanting to create an "Un-DO" button, that will take you back to before the LAST move?Create another partial class that stores each move.Then set the LastMove details after each move.Then, you can go back to those...
15 Mar 2015 by HKHerron
Or you could even store every move by using an Array.Then you could do something like this: public partial class Form1 : Form { double q = 0; bool turn = true; //true = X turn, false = Y turn int turn_count = 0; public LastMove[] lMove =...
18 Nov 2020 by DoingWork
Dear Friends My Main application is 32-bit application. It is limitation due to some third party DLLs that I can't convert it to 64-bit. Now I have created a new 64-bit library project and compilation is successful but on application startup it...
17 Nov 2020 by Richard Deeming
You can't load a 64-bit library in a 32-bit process, or a 32-bit library in a 64-bit process.
17 Nov 2020 by TheRealSteveJudge
Please have a look here: Process Interoperability - Win32 apps | Microsoft Docs[^] There it is said: On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL). Additionally, a 32-bit process cannot load a 64-bit DLL. ...
18 Nov 2020 by RickZeeland
Here is a possible solution: How do I use 32-bit dll in 64-bit app?[^] But it does not look very robust to me, another option might be to split your application in a 32 part (with all the legacy dll's) and a 64 bit part and let them communicate...
21 Jun 2017 by ilostmyid2
In a Windows application form, I need to put a time picker. I think I may select between System.Windows.Forms.DateTimePicker or Telerik.WinControls.UI.RadDateTimePicker. It's not to be used to select a date. It's to be used a time in a 24-hours. But the time should be aligned in half-an-hour,...
21 Jun 2017 by Richard MacCutchan
See the Remarks section at DateTimePicker Class (System.Windows.Forms)[^]. [edit] Set the properties according to the remarks in the link above to show a simple up down time control, and add the following code to the ValueChanged event handler: DateTime dt = dateTimePicker1.Value; int mins =...
13 Nov 2018 by ilostmyid2
In a WinForm application, I've a DataGridView control. I don't add any column to it. I just set its DataSource to a list. The list is of type Field which is a class I wrote. It contains of three members, Name of type string, Type of type string and Len of type int. This causes no problem and the...
10 Jul 2013 by havilove
Im trying to make a plugin for Age of Empires (AOE). I want to display a message on screen of game when im playing I think must use SetWindowsHookEx and draws overlay in response to WM_PAINT messages. But im not strong with Hook. Im searching for a simple code snippet which can help me draw a...
5 Jan 2015 by Luiey Ichigo
Hi,How to view a subitem content when hover mouse on it? I have search and they using tooltip to view the subitem on listview mousemove but nothing show up. Some of my data too long which exceed my column width. So I want to preview the data by hovering mouse on it. Below are what I have...
6 Jan 2015 by Ravi Bhavnani
See this SO answer: http://stackoverflow.com/questions/11839323/c-show-tooltip-on-subitem[^]./ravi
1 Mar 2014 by Andreas Gieriet
Before talking about implementing in C#, please try to state the problem in your own words and draw a solution independent of the C# implementation."offsetting" a polygon has no commonly known meaning - at least not to my knowledge.What I get from this question and your former fruitless...
31 Mar 2014 by CPallini
That's very simple. You just need a Dictionary. For every string in the list:Use the Dictionary's ContainsKey method to find out if the string is already in the Dictionary. Then if such method returns true increment the corrensponding value. On the other hand, if it returns false,...
5 Oct 2014 by morzel
How to shoot paintball marker with relay, Arduino and .NET Winforms
13 Jan 2014 by OriginalGriff
It doesn't quite work like that - we are not that kind of site.If you want someone to write your code, you have to pay - I suggest you go to VWorker.com and ask there.But be aware: you get what you pay for. Pay peanuts, get monkeys
11 Nov 2013 by Muhamad Faizan Khan
I Have two Forms. 1. Form1 Include Databinds Control Gridview /textboxes etc2. Form 2 It contain Search FormI can access Form2 tow From1.Now the problem is i want to render Searched result on form 1 Controls which i searched in form1.How can i do this i am using Three tier...
6 Nov 2013 by Sergey Alexandrovich Kryukov
I already answered recently: How to pass Searched Data From Form 2 to From 1[^].Did you ignore this advice, or did not understand it? You did not ask any questions on it. If you understood it, you would also understand that rendering of search result would not make a specific problem. In my...
6 Nov 2013 by Ziee-M
i found this post: solution 2 check ithow to enable the buttons which are in parent form from child form in C#.net[^]hope it helps!
11 Mar 2021 by Sonhospa
Hello Gurus :-) I observe a very strange behaviour of my code and don't know what I might accidentially have done... In my windows form I have a TabControl that holds 4 different TabPage elements, on each of which other controls are placed...
11 Mar 2021 by Jo_vb.net
Do you use language resource files for this form? Did yo change the screen resolution or DPI settings on your pc? I use always split containers and/or tablelayoutpanels to place the controls - this keeps them where they should be when the form...
6 Apr 2011 by garfield185
Hi.I am trying to load some information from a query into a datagridView. This query return an integer and some decimals. After loading the information into the DataGridView , I need to take that first number and format it ( it is a date, so I change it from (int) yyyymmdd format to...
6 Apr 2011 by garfield185
I solved it changing a little the sql statement:MYDATE (INT TYPE ON DATABASE)Instead of doing :SELECT MYDATE FROM TABLEwhich made the field on the DataGridView be an Int32, I changed to:SELECT CAST(MYDATE AS VARCHAR(8)) MYDATE FROM TABLEThis way, the DataGridView...
31 Aug 2010 by demouser743
I would like to have an array of treenode in such a way that if i add a custom node along with that the remaining Nodes declared in the array should be added as child nodes to that custom node added.UPDATE: Answer added by OP himself.
30 Aug 2010 by Christian Graus
Sounds like you need to write the code to suit your need, I don't believe it exists otherwise.