winforms

WinForms to WPF - How do we get there from here?

Is there a practical way for us to slowly evolve a WinForms application to WPF without creating a support nightmare for ourselves with strange interop scenarios? Background info: We have a large battleship gray WinForms application that is heavily used by an internal group of about 60-75 users. We're starting to run into places where ...

Best Chicago Font alternative

I'm just after reading the "User Interface Design for Programmers 2001" by Joel Spolsky. He suggests Apple Chicago as a good font solution to a WinForms App. I would like to know what can be the best alternative of Apple Chicago font in Windows environment. Do you know any out-of-the-box or free-to-download mono spaced fonts that look el...

In a C# application, should a DB Connection be created once, or everytime a SQL statement is executed?

In a C# application, should a OleDBConnection be created once, or every time a SQL statement is executed? I am looking at C# code written by someone else. Every SQL statement is preceded with the creation of an OleDbConnection object whose connection string points to an MDB database. Is it appropriate to create an OleDbConnection obje...

Dynamic Variable Name Use in C# for WinForms

Not sure what is the best way to word this, but I am wondering if a dynamic variable name access can be done in C# (3.5). Here is the code I am currently looking to "smarten up" or make more elegant with a loop. private void frmFilter_Load(object sender, EventArgs e) { chkCategory1.Text = categories[0]; chkCateg...

ComboBox causes strange behavior on a Windows Form

I'm noticing some strange behavior when I add a ComboBox to my Windows Form: when I resize the Form without a ComboBox, it behaves correctly and the File menu stays where it's supposed to stay even when I drag the right corner as far left as possible. When I add the ComboBox and I try to do the same thing, then the File menu gets pushed ...

How to handle a lot of controls on a Form?

I am wondering how to handle a Form with a lot of controls. Do you stuff all of the handling code into the Form? This is how I have been doing it, but my most recent project is getting out of hand because of all of the controls that I need to work with. I have menus, multiple toolbars, tabcontrols filled with controls, statusbar, ... ...

How do I handle events from controls inside a User Control derived from a Tab Page meant to be added dynamically to a Tab Control at run time?

I created a User Control derived of a Tab Page with certain controls such as ListView, Buttons, and Textboxes in it, to add Tab Pages to a Tab Control dynamically during run time. How do I handle the events from such controls within each User Page (multiple instances of these user control tabs) in my main form where my Tab Control is go...

Good way to ensure that a property on a UserControl gets set?

If our UserControl requires certain properties are set for it to be useful, what's the best way to ensure they are set? Even if just as a note to self and/or close colleagues. We've tried using an Initialize method, but that's already caught us out because we forgot to update the Initialize in one instance, having slightly changed the d...

Changing the default culture info of my Application

Hi, Each thread inherits the default Windows culture unless you change it by accessing the current thread through services provided by the System.Threading namespace. Do you know if it possible to change the default Application culture info instead of setting eac new thread with the culture info of its parent. Thanks! Ronen ...

Winforms: Open a second modal dialog in an already open modal dialog

I have an open modal dialog and open again a modal dialog from this dialog (with ShowDialog) The problem is now that the parent modal dialog is not locked and when I click on it the second modal dialog, it moves to the background. When I close the first modal dialog, the second one still remains on the desktop. How can I prevent this beh...

High-performance .NET sweep/oscilloscope graph component needed.

I'm searching for a .NET graph component. It should be able to plot data in sweep (oscilloscope) mode and if possible also as a scrolling waveform. On the x-axis I want timestamps (e.g. 18:25:00) and it should be possible to plot two vectors (DateTime[] and double[]). That is, data points are not equally spaced, but come with their own t...

Display 2 Forms, side by side

I would like to display 2 forms side by side. Frm1 will call Frm2. The problem is, if Frm1 is too near the edge of the computer screen, when Fr2 is shown, part of it will be outside the screen. How do I make it so that if Frm1 is near the right-side of the screen then Frm2 will show on the left-side of Frm1 and vise-versa? Thanks ...

C# simple DataBinding question

I am trying to make a (very) simple Data Binding test, but it doesnt work as I expected... Say I have the following classes: // this class represents some kind of data producer public class DataSourceClass { public string Data { get; set; } public DataSourceClass() { } } //this form holds the TextBox c...

DataGridViewComboBox null values

I have a Windows forms DataGridView with a combobox column. The combo box column is bound to a data source that is populated from a Linq to Entities query. I would like users to be able to select "Nothing" in the combo box (assign a value of NULL to the underlying data source). How can I accomplish this? ...

System.OutOfMemoryException on accessing an Interop

I am using Interop.WinHttp and when I run the application it gives me this exception on a line of code that is using Interop.WinHttp like this: System.OutOfMemoryException: Retrieving the COM class factory for component with CLSID {91E2EAD3-AB7E-4D5C-88DE-F7FA382172BC} failed due to the following error: 8007000e. WinHttp.WinHttpReques...

Selecting Text in ICSharpCode Text Editor

Hi all, I am trying to select lines of text in a ICSharpCode TextEditor. As well as make the textbox go to the specific row. The application is windows form app built in VS 2010 in C#. The reason I am using the text editor is for the code highlighting and line numbers etc. I dont really have too much experience using windows forms s...

Access windows control from Backgroundworker DoWork

Hi, my issue is the following: I have a windows form in which I've placed a LayoutPanel, when the forms Loads, multiple controls like: textboxes and labels are being added to the LayoutPanel. Then on a button click, I need to process the data entered by the user on those dynamically created controls. For that purpouse I use a Backgroun...

Looking for a great Wizard example implemented with WinForms and/or an advice regrding design.

Disclaimer: In this question tab, page, an dialog actually mean the same thing, sorry. My excuse: I am not sure what the final product should look like - a bunch of separate windows or all in one. I am looking to improve an existing, hard-to-maintain Wizard baked with WinForms. I need to try to keep the look and feel about the same, but...

How to align/ orient a progress bar to be vertical in a tool strip?

When i add a progress bar to tool strip, it is horizontal. How to align/ orient a progress bar to be vertical in a tool strip which is inside a tool strip container? ...

Implement mouse over and mouse click event for specified screen region

Hello guys, I have some specified region on the screen (not on the form, but on the screen), for example, it's region in the upper-right corner of the screen. Rectangle specifiedRegion = new Rectangle(*,*,*,*); I want to implement mouse over and mouse click event for that region. When mouse was over that region, some button or pictur...