winforms

How to detect .Net application type?

I have a library that needs to respond to exceptions in different ways depending on whether it is running in a Console app, WinForms, AspNet or Windows Service. I have experimented with looking at various properties in the System.Windows.Forms and System.Web namespaces, but I can't find a reliable way of detecting exactly which kind of ...

WebBrowser control won't print from C#

I've got a WebBrowser control on a WinForms app that is loading XML which is converted to HTML/CSS. Looks beautiful if I just want to view it there or in a regular browser. When the form loads, it's supposed to navigate to the file, then when the OnDocumentCompleted event fires, it should set the header, footer, and default printer nam...

What is the proper way to create a Form unobscured by the Windows taskbar?

I dock the taskbar to the left, which causes many windows to open underneath the taskbar. None of the System.Windows.Form.FormStartPosition values take into account the taskbar except for Manual. Is this by design? It's frustrating. I want to respect the default monitor and window position values that the OS should enforce. ...

Data Binding and throwing exception in setter

Hello, Let's say I have a simple class public class Person { public string Name { get; set; } private int _age; public int Age { get { return _age; } set { if(value < 0 || value > 150) throw new ValidationException("Person age is incorrect"); _age = value; } } } Then I want to setup a bi...

Can System.Windows.Forms.ColumnHeader use a different image then one from the main ImageList?

I have an ListView set up to sort, and I have that working well. However, when the ListView is sorted, no indication is provided as to the current sort column and order. I tried a solution setting the ColumnHeader.ImageKey property whenever sorting, but I want to be able to use images that aren't the size specified by the ListView's Sm...

DataGridView ensure application wide consistency

In our application, we are going to have several finder dialogs. The UI of a finder dialog is simple (text box, datagridview result, ok button, cancel button). The only real change between the different dialogs is some label text and the grid binding source. We want to enforce certain properties (like full row selection and read only mod...

How to databind a Linq2SQL collection to winform textfields

Hi, I am a little bit puzzled as to how I can optimize my program by utlizing DataBindings. My program uses several Linq2SQL bound Objects storing the Data. All ORM objects are stored in a hierarchy. In a second GUI project I am displaying this data in some Text and Combo Box fields. The data structure hierarchy is as follows: JobMan...

Combobox Dropdown Caching

We have a VB.Net application that has in the region of about 80 unique comboboxes spread over 15 Windows. Currently when a Window is loaded, the Comboboxes retrieve their contents directly from the SQL database. This is quite inefficient as the content of the comboboxes rarely changes, so it would make sense to retrieve all the combobox...

Data binding dynamic data

Hello, I have a set of 'dynamic data' that I need to bind to the GridControl. Up until now I have been using the standard DataTable class that's part of the System.Data namespace. This has worked fine, but I've been told I cannot use this as it's too heavy for serialization across the network between client & server. So I thought I cou...

How to decide where to store per-user state? Registry? AppData? Isolated Storage?

When should the Windows Registry be used for per-user state, and when should we use the filesystem, particularly the user's AppData folder? (eg, C:\Users\USERNAME\AppData). Where does Isolated Storage come in? Is there a pretty firm rule, or is it just a fuzzy thing, like "use the registry until it becomes too much data to store in the...

ImageList / Image OutOfMemoryException

I'm suffering from an OutOfMemoryException when obtaining an Image from an ImageList I've been unable to find an appropriate solution to the problem. I've got a Custom ListView control, which has attached to it an Event for the drawing of ListViewItems. This then calls a static method which is designed to draw the item. For a ListView ...

(C#) Windows Forms - Transparent background whilst capturing mouse events?

Hi everyone - there seems to be a similar question to this on here but with the 'opposite' problem (He didn't want mouse events captured). I have a form with a panel. The window is borderless and set to the exact size of the panel (for all intents and purposes, it is as if the panel is 'free floating'). I can set the panel's BackColor t...

MS Office PIAs "backward compatability"

Hi there, I just wanted to know something. I've successfully completed a WinForms app with MS Word integration - the app writes to mergefields in a Word Template. I did the template using MS Word 2007, but saved it in compatible mode as a 97-2003 '.dot' file. Due to the fact that I have Office 2007 installed, I'm using version 12.0 of...

Invisible form fields in NSIS?

Is it possible to create invisible form fields in an NSIS installer? I'm using nsDialogs and currently have a checkbox that toggles some fields from to readonly/non-readonly by using: SendMessage $TextBox1 ${EM_SETREADONLY} 1 0 I'd like to make this control visible / not visible. Is this possible? How? ...

Why would I see ~20% speed increase using native code?

Any idea why this code: extern "C" __declspec(dllexport) void Transform(double x[], double y[], int iterations, bool forward) { long n, i, i1, j, k, i2, l, l1, l2; double c1, c2, tx, ty, t1, t2, u1, u2, z; /* Calculate the number of points */ n = (long)pow((double)2, (double)iterations); /* Do the bit reversal */ ...

{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}

Hello, I have built a simple application framework around Unity. I.e. Form and user controls are discribed as xml and built dynamically. I have a form which contains a ComboBox which when closed causes the error detailed below. The problem does not occur if the ComboBox is substituted for a ListBox control. Some googling raised som...

Form Contols in Outlook Interface

I want to make an interface that looks like Outlook. In the center pane, outlook contains a styled list that has multiple lines of formatted text and icons. What control would I use to achieve this effect? Thanks. ...

Generating Member for labels: Any reason I should?

I had read in another post here on SO that when possible you shouldn't Generate Member's for labels. I was wondering what some potential DRAWBACKS to this would be? Am I correct in saying that the benefit is increased performance? Anything else? I have a winform app with 100's of labels. Is there any benefit to not generating me...

WndProc with no visible form?

I want to create a form on a second thread that will receive messages in it's WndProc method. What is the recommended way to create an invisible form like this? Is setting "ShowInTaskbar=false" and "Visible=false" enough, or is there a "cleaner" way? ...

WinForms: Foreground color of progress bar always green on XP Luna

The WinForms ProgressBar control allows its foreground color to be set. While this normally works fine, the foreground color setting seems to be ignored on XP when using the obnoxious Luna style: it is always green. Similaraly, XP Luna seems to ignore the 'Style': Although I have set it to 'Continuous', the progress bar is always drawn ...