WinForms is the informal term given to the graphical application programming interface (API) included as a part of Microsoft's .NET Framework, providing access to the native Microsoft Windows interface elements by wrapping the existing Windows API in managed code.

learn more… | top users | synonyms

11
votes
2answers
234 views

Displaying data from a database onto a form

I'm a beginner to .NET and could you guide me to right direction. My problem is based on the following code. Here I have 4 variations of same method and all 4 variations are working fine. What is ...
2
votes
2answers
36 views

WinForm plugin architecture

I have been developing this plugin architecture, mostly for fun and education, its a simple WinForm with some plugin logic and two plugins, i want to know if there is a better way of doing it. ...
4
votes
2answers
97 views

Can calculation of word wrapping be made notably faster?

I need to re-wrap a text so that it fits a given width, font and DC. The result needs to be an array of lines. I use the following code: ...
6
votes
1answer
83 views

Small C# Pong game

I recently made a 140-lined Pong game in C# using forms. Since I'm very new to programming, I'd like if somebody would please read it and give me advice on where to improve, what you believe I did ...
3
votes
2answers
47 views

Handle multiple menu click events in one Sub

I have multiple menus that will change languages in one Sub that will handle multiple events of the menus click, It is working for me right now, I'm just wondering if there is better way to do it... ...
5
votes
1answer
136 views

Fastest image upload into SQL database

Hello I am trying to upload an image (screenshot from desktop) to SQL database as fast as possible. I would like to optimize my current procedure in terms of speed: ...
4
votes
2answers
128 views

Chaining Tasks with async/await

I've been trying to learn how to use the TPL for quite some time now. Basically I'm trying to fire off a group of Tasks, wait for them to complete and then fire off another group of tasks, waiting for ...
1
vote
1answer
128 views

Winforms Enhanced ListView Class

Here is an "enhanced" Listview class. You can just add it your project and you're good to go. Most of the code came from here and there. It's not perfect by any means, so any input is appreciated. ...
3
votes
1answer
120 views

Naive implementation of attached properties for WinForms

I need to implement something like "attached properties" from WPF that targets WinForms. What I came up with seems to work. Can you find any issues with it? The helper class and example are shown ...
12
votes
3answers
598 views

Is decoupling necessary for very small applications?

I threw together a small solution for my organization today for some basic data review and approval procedures. This particular application will likely not change or add functionality at any time. ...
10
votes
2answers
326 views

BackgroundWorker vs TPL ProgressBar Exercise

I wanted to fiddle around with the BackgroundWorker and Task classes, to see how I would implement a given task with these two ...
5
votes
3answers
1k views

loading a combobox with an enum and binding to it

I have the following code to load an enumeration into a bound combo box, but am not quite happy with it. I would prefer to store the actual enum value in the combo box and bind directly to it. ...
14
votes
9answers
2k views

Making these conditions shorter

The problem I'm dealing with is the length of my code. I have lots of code like this: ...
14
votes
2answers
326 views

Simple temperature converter

Below is my first attempt at programming a Celsius to Fahrenheit converter in C# winforms. I'm looking for tips and advice on improving my style and what I can do to make the code more ...
2
votes
1answer
106 views

Reading a certain pixels color from a window

I'm currently reading a certain pixels color from a process window like this: ...
1
vote
1answer
82 views

Executing method on a certain interval + offset

I would like to execute a certain method at a given interval. The reason why I can't use a timer + its event handler right away is because I want to add an offset to each tick (100ms in my example ...
2
votes
3answers
553 views

Winform that exports a datagrid to Excel

I've just created a winform that exports a datagrid to Excel. Originally the file was never shown, but I was asked to give the option. So I put in a checkbox and modified the code. Is my if/else ...
2
votes
0answers
295 views

C# WinForms - Custom Application.Run Bootstrap Routine [closed]

I've got to maintain a legacy application (actually a number of applications) and currently most of the startup-settings (like upgrading App.config when the version has changed, check Database against ...
2
votes
1answer
126 views
4
votes
3answers
374 views
0
votes
1answer
68 views

Searching for a better implementation to EnumBase

In a former question on SO I described a problem with a construct called 'EnumBase'. As I sad there, I am not involved when basic implementation happened. So I'm not sure why the thinks are a they ...
1
vote
4answers
172 views

Foreach statement for two OfType<>

How would I write a foreach statement that includes both of these statement together ...
0
votes
2answers
1k views

Multiple forms for accessing records in database

I have a main form for adding and deleting records and a button that opens a child form that displays records from an access database. Child form will have buttons for moving though the rows like ...
0
votes
1answer
220 views

Is it necessary to move OpenFileDialog code for opening the files and put it into a separate method?

I want to separate the code inside my Add button click event from the code in order to make my code looks more arranged. this is my code before these changes (i am ...
1
vote
1answer
124 views

Class design question

I have Winform application and I want to separate the button click event from the main form. My application has Add button which adds files into my Listbox and ...
5
votes
2answers
474 views

Generic Task Blocking Queue

A generic blocking queue has the following properties: It is thread-safe. It allows queuing and de-queuing of items of a certain type (T). If a de-queue operation is performed and the ...
2
votes
1answer
419 views

Code review for a windows form that generates invoices

I have a C# program that I would like to have reviewed. I am new to programming and want to know how it could be improved. It is a Windows Forms project that generates a pdf using the iTextSharp ...
0
votes
1answer
343 views

selecting an item in a listbox to assign it as a temp variable - Review Code

I got this answer here: http://stackoverflow.com/questions/15902299/selecting-an-item-in-a-listbox-to-assign-it-as-a-temp-variable Suppose you have loaded the ...
-1
votes
2answers
3k views

Insert to datagridview when SELECT query has WHERE condition [closed]

I use this code to Load and Insert data to a table using a DataGridView in a C# windows application. ...
1
vote
1answer
1k views

'Universal' WinForms TextBox Text 'Two-Way' Binder

Below is the code of a custom C# class I have called UniversalTextBoxTextBinder. I'm interested to hear the code review comments to find out the limitations of this 'universal' solution as well as to ...
1
vote
2answers
73 views

Get Set vs passing class at init?

I have the main form with a list inside and i need to open another form and edit the list in the main. Generally i'm doing something like ... ...
5
votes
5answers
5k views

Faster way of reading csv to grid

I have following in Windows Forms .NET 3.5 It works fine for csv with records less than 10,000 but is slower for records above 30,000. Input csv file can can any records between 1 - 1,00,000 records ...
7
votes
1answer
338 views

Is this code to hook into a .NET window that we don't own safe? Can it be made safe?

I have some code that is used to hook into third party code. It goes pretty much like below (mind you CodeWeDontHave can't be posted because we dont have the source). I have an issue where sometimes ...
4
votes
2answers
2k views

Timer Tick Event only to execute at specific time

I have a timer that is only supposed to tick between x and x on weekdays. I have used the following implementation. ...
2
votes
1answer
414 views

Automatic Databinding of controls to Model [closed]

I have developed a prototype framework (MVVM) where control on the form is bound to a model property using a naming convention and its UI behavior is controlled using custom attributes. As of now ...
2
votes
3answers
592 views

Better way of showing/hiding controls based on event?

I have the following code in a portion of my program that hides/shows certain elements based on the status of a certain checkbox: ...
3
votes
2answers
168 views

Any way to speed up this UPDATE?

SQL: ...
5
votes
2answers
209 views

Ideas for reducing repetition in control binding

I have seven checkboxes on a data maintenance WinForm, which indicate the days of the week that are "valid" for a particular operation to be performed. These "map" to a list of DayOfWeek enum values ...
1
vote
2answers
2k views

Need help in MVC Winform example project to add a record into the DB [closed]

I want to learn MVC pattern using winforms and I have read some tutorial to understand. Now, i'm working on my own example to just add a customer records in a database using MVC pattern. The ...
1
vote
1answer
1k views

how to self-host wcf in winform without another windows process [closed]

I have a windows application and want to self-host a wcf in it. This MSDN article walks you through how to self-host wcf in a console. Jason Henderson's article demonstrates how to call the service. ...
4
votes
2answers
3k views

Moving List View items from one list to another

I'm writing a form that contains 2 ListViews with a set of 4 buttons. 2 move all the items from one to the other in each direction, the other move only selected items in each direction. Nothing fancy ...
2
votes
1answer
162 views

What should I do to improve this snippet

Though it works I wonder if there might be a better way to do this. I would like to reuse this loading and establishing of fields of another class(es) (the static TileMapper class mentioned at the ...
2
votes
4answers
639 views

Refactoring Event Handlers - How to go about this for growing WinForms application

I have a class with approximately 140 menu buttons in a nested ribbon-style menu over a canvas type area within a WinForms application. As a result of this, a large swathe of my codebehind file ...
1
vote
1answer
672 views

Please look over my methods. Best Practice?

I have an application that has multiple functions. Two in paticular will query a remote computer using WMI, and return the installed printers in a datagridview. The other is a new method that will ...
0
votes
2answers
8k views

Getting data from database and then outputing it to the DataGridView

I am at the point where I feel that I am not doing it right. It works and does the job, but I am sure that there are more efficient and smarter ways of doing it. I would like to see if there is a way ...
4
votes
1answer
266 views

Is there a more elegant way of arranging my forms?

I'm a rather novice programmer who recently came up with a solution that works for my project, however I'm always looking for ways to improve my code. So essentially, I have a settings form that ...
2
votes
1answer
1k views

Binding FlowLayoutPanel

So I'm trying to create a Bindable FlowLayoutPanel that can take a DataSource and map it the specified generic parameter controls. Only minimal requirements are to have a selectable index and to be ...
10
votes
1answer
698 views

UI repetitive code - what pattern to use? [closed]

I have two different windows forms project which contain forms with similar UI/code. For example, I have several forms that have 98% code tha same, the only difference is that one they call different ...
1
vote
1answer
392 views

Persisting objects in a ListBox ObjectCollection

I have a C# WinForms app containing a ListBox control, which I populate with objects of type BukkitServer. When an object is ...
2
votes
2answers
464 views

C# Winforms: Is there any way to improve this simple custom Textbox code?

I have been working on Custom TextBox control, which only allows alphanumeric characters. Note that I have not restricted characters from KeyPress, KeyUp event as I don't want to restrict copy/paste ...