winforms

How do I gracefully handle hibernate/sleep modes in a winforms application?

I am writing a windows form application in .net using C#. I am running into a problem that if my program is running when the computer goes into the sleep and/or hibernate state (I am not sure at this time which one, or if both, cause the problem), when the machine wakes up again the program just hangs. The only way to exit out of it is...

Day Change Update Problem

C# - Winforms - SQL Server i am building an application which displays some data on the screen of the current day which it gets from the database... the application is like a desktop widget so the data is always visible on the desktop the scheme i implemented is when user commits some change to the data, after the update query i ...

Fill ComboBox with List of available Fonts

How can I fill a combo-box with a list of all the available fonts in the system? ...

Performance issue on the update of a DataTable bound to a Datagridview

I have a dataTable bound to a DatagrindView and would like to update a selected column. My DataTable(displayDT) and my datagridview1 have the same layout: DateTime item1 item2 item3 1/1/2010 100 100 100 1/1/2010 1:00 120 110...

Convert Winform App to Console app

Is there a quick and dirty way (or a VS Macro) to convert a WinForms app to a Console App? I have a number of these apps that are no longer needed as Winforms apps. I suppose I could create a bunch of new projects and copy paste modules and classes over, but if it's just a matter of removing the single form that I have and editing/deleti...

Converting old VS 2002 Windows Forms projects to newer versions

I have an application that was started in C# 1.0 using Visual Studio .NET. As part of a partial rewrite/upgrade, I would like the application to take advantage of the form auto-scaling features in Windows Forms 2.0. Those features rely on setting the AutoScaleDimensions property, which is supposed to be done by the designer. New custom F...

Writing huge amounts of text to a textbox

I am writing a log of lots and lots of formatted text to a textbox in a .net windows form app. It is slow once the data gets over a few megs. Since I am appending the string has to be reallocated every time right? I only need to set the value to the text box once, but in my code I am doing line+=data tens of thousands of times. Is ther...

Windows requires a click to activate a window before a second click will select a button. How can I change this?

My application is a C# Windows Forms Application and .Net somehow makes the default behavior of my main menu bar and tool strip buttons to be that you have to first click on my app's window (anywhere), before it will let you click the menu or tool strip button. How can I change this? Old apps like Notepad and WordPad don't behave this w...

Refactor custom wizard to reduce flicker

I have implemented a custom wizard control in C# windows forms by creating a base form which has the shared components and then making child forms for each step of the process. I then have a class which hides/shows the child forms when you move from one step to another. The problem is that flickering is bad when moving between forms. ...

C# WinForms - Databound simple components with Cancelable form

How can I implement a form with simple components (text boxes, comboboxes) bound to an object's properties and have Save/Cancel support? I have tried the code snippet at http://fgheysels.blogspot.com/2009/06/winforms-databinding-on-cancellable.html but I dont know what is required for this to work binding to object properties. This is ...

How to Programmatically Fill Out HTML Invoice Form?

I have HTML template which has empty forms. How can i fill these forms from Winform? Should i create a new class called CreateInvoiceHTML which creates invoice programmatically? I haven't done this before, i need some quick ideas to make sure i don't go to the wrong track. ...

Validating input for Textbox on C# Winforms

I am attempting to validate that the input into a textbox on a C# winforms conforms to a valid pattern. The pattern must be a string that consists only of the following characters 0 to 9 A to Z "-" "/" I am looking at using the "Validating" event on the textbox to perform the validation but I am struggling with the correct Regular ...

Multi-segment winforms progress bar?

I'm wondering it this is a really bad usability idea, so I'm open to feedback. I need to perform two steps on a large number of items, with step 2 starting any time after step 1 has completed. However, Step 1 for Item 2 can begin any time after Step 1/Item 1 has finished, and even while step 2/Item 1 is going on. Is a multi-segment pro...

When to use THIS keyword when working with controls on form in C#

I am still far away from mastering C# but child in me pushing me to programming day by day. When I making WinForm application I want to change and use lot of controls pragmatically. What I do not understand is, When I need to set this.control keyword and when I should use just control. Sample: If I want to cgange text of my label I can w...

folderbrowserdialog on C# winforms

I am using folderBrowserDialog in my winform. I need the default or initial path to be a network location. for eg: folderBrowserDialog1.SelectedPath = @"\\server1\foo\bar\"; This does not work. My system is on the right network and I am able to access the directory thru my browser and run command. Is this a non-feature? or is there...

Avoid selecting new node on key press in TreeView

When TreeView (WinForms) has focus pressing key selects the node whose text begins with a key character. Is there a way to avoid this? First thing that came to my mind was to create Control that inherits from TreeView, and override IsInputKey so that it returns false in all undesirable cases. But it doesn't work. Is there any way to o...

How to serialize and deserialize a form?

How do I serialize and deserialize my main form (and its controls, subcontrols, their values, etc.)? Edit, for clarification. Currently I am writing the current value of each control to an .INI file, one by one and reading it back when the program is next run. Every time I add a new control, I have to remember to update that save/load...

Aligning text on diagonal path

I have two points that draw a line when connected. The line can be both vertical horizontal, vertical, or (most commonly) diagonal. I would like to try text along this path. I'm using C# and WinForms, but I think that isn't as important as some simple psuedo-code that may include some math (trig?) needed to find the angle of the path t...

Winform doesnot show up when i tried to open from a backgroundworker_RunWorkerCompleted event?

Hi the detail of my action is i have a winform which contains only progress bar which i made to do some calculations and stored the final value in db.for this i used progress bar and backgroundworker thread. i am doing all calculation in backgroundworker thread event doWork event. When backgroundworker is finish it calls RunWorkerComple...

How can I move all the controls in a panel on form resize?

I'm playing around with a project, C# .NET 4, and I'm kind of stuck. I have with a panel that will be dynamically filled with checkboxes based on the number of items in a folder, which works fine. But when I resize the form I want the checkboxes to move in the panel, like a little grid of checkboxes that takes up what space it can. Th...