winforms

C# Form resx usage for programmatic strings?

Hi All, Had a basic WinForm question: By default a resx file is created for every form or usercontrol (along with the designer.cs). This resx works fine for all the controls and the text added to the controls via the UI. I was wondering if I could use the same resx to add strings which have to be used programmatically and based on cond...

c# winforms Child form load problem

I have a dialog-based application. I need to show a child window like this: (1) First, the application's main dialog window will show up, (2) then, a child dialog window will show up automatically on top of that. You know, it is not enough to call the child window's ShowDialog() in the parent window's constructor or load event. Coz i...

Performance regarding return type for LINQ query compatible with automatic sorting

Hi! this isn't really an issue, but more of a concern that I would appreciate some input on please. Winforms C# .net3.5[sp1] Visual Studio 2008 using Linq2Sql (more specifically PLINQO...which is fantastic btw!). I have a resultset returning +/- 19000 rows of data (with about 80bytes of data per row) and opted to push the data retrieva...

How can I force validation of a form / control in Compact Framework?

Is there any way to force control validation in .NET CF? In full .NET there is the Validate() method, but it is missing from CF. I'm trying to make a control bind data back to the model when closing the form, but clicking the main menu button doesn't seem to steal focus from the control and the Validating and Validated events don't fir...

What's the second-best way to make a skinnable user interface component?

I've been asked to make one of the components, which mimics a real-world appliance, in our application have a custom appearance, which varies depending on the make of the appliance being mimicked, so I need to make it skinnable. Now, I'm aware that the best way to do custom appearances in user interfaces, is not to do that at all; but I...

F#: Namespace not defined when trying to open System.Windows.Forms

I am using Visual Studio 2008 Integrated Shell with the F# CTP (October). Everything works fine, but when I am trying to open System.Windows.Forms, VS gives an error: the namespace 'Windows' is not defined. However, it works when I try to open the namespace in F# interactive. What am I doing wrong? ...

Windows Forms: isLoading vs event disconnection

In Windows Forms programming, I have this general problem. When the page is loading and populating, in some cases I don't want the logic in the event handlers to run. The event handling code is primarily to respond to user interaction, but it also runs when the controls are manipulated programmatically. In the past, I've seen people u...

Programmatically click on a CheckBox

Hi, Is there a way to programmatically generate a click event on a CheckBox? I am looking for an equivalent to Button.PerformClick(); ...

How can I construct this string in a nicer fasion?

I have a tool with a configurable delay (Timespan), and I want to set the text of a label depending on the value. Here is my code as it stands: StringBuilder time = new StringBuilder(); if (Settings.Default.WaitPeriod.Hours > 0) { time.AppendFormat("{0} hour(s)", Settings.Default.WaitPeriod.Hours); } if (Se...

Implementing Mask property to display data in DataGridView Winforms control

I'm aware of articles and examples about using MaskedTextBox for editing data in a DataGridView control, i.e. DataGridViewCustomColumn DataGridViewMaskedText GenericDataGridView etc. What I need is to display string values (like telephone numbers, SSN...) with a given Mask in DataGridView control. I'd like to set Mask property for a...

What's the fastest way to decompress JPEG images in C#

I need to write an app to playback a DICOM multiframe image. Each frame is stored in JPEG format. All the frames are stored consecutively in one file. Right now, I read out each frame data and pass it to the following routine to construct a Bitmap for display: Bitmap CreateBitmap(byte[] pixelBuffer, int frameSize) { B...

How to not pass around the container when using IoC in Winforms

I'm new to the world of IoC and having a problem with implementing it in a Winforms application. I have an extremely basic application Winform application that uses MVC, it is one controller that does all the work and a working dialog (obviously with a controller). So I load all my classes in to my IoC container in program.cs and crea...

Effective auto-complete for WinForms DataGridViewComboBoxColumn

I've build a number of WinForms applications that use DataGridView grids with combo box columns. There seems to be a basic flaw in the user interaction for these controls. Typically my audience is made up of business users who what to perform keyboard driven layout, and they expect auto complete selection when they encounter a dropdown...

Cancelling Windows Forms Events

I have a windows form. It has a ComboBox and a DataGrid I have a Leave event on my combobox and I have a double click event on my datagrid row The idea is that on leaving the combobox, if the value of the combo box changed than use the new value to reload the datagrid. Let's say the combobox is displaying a value of 1 and for that va...

setting title in c# drop down box

What is the easiest way to set the default text selection in a drop down box, and make it so the user cannot select that item? The only way I know currently how to do it, is just manually checking that it isn't checked. Thanks! ...

How to store int[] array in application Settings

Hi, I'm creating a simple windows Forms application using C# express 2008. I'm an experienced C++ developer, but I am pretty much brand new to C# and .NET. I'm currently storing some of my simple application settings using the settings designer and code like this: // Store setting Properties.Settings.Default.TargetLocation = txtLoca...

BindingSource.Find Multiple Columns

Is it possible to use the Find method of a BindingSource on multiple columns? For example, say I have a gridview displaying current pets; two comboboxes, cboPetType and cboGender; and a button to create a new record into the Pet table based on the values of these two comboboxes. Now, let's say I only want one of each PetType/Gender c...

Image.Save question (save CMYK image to CMYK image)

In Windows Forms Application, I'm trying to open the image (CMYK tiff), add text, and then save back to CMYK tiff image, but when I opened the output image in Photoshop, it was RGB image (the colors looked different from the input image). Following is the code and I appreciate if you could help me. Image^ chartImg = Image::FromFile( "us...

How to start to implement a drag and drop between different processes?

The application that I am developing is a windows form application written in C#. It has a treeview on it. Each of the treeNode stores some data. What I want to do is to open two copies of the application, drag some of the treenodes from one application and drop to another. The data the treenodes store should be transferred to another a...

Set print orientation to landscape with a c# Winforms WebBrowser Control

I need to programmatically change the print orientation for one of my webbrowser controls in a winforms app. From what I'm reading in other posts... it looks like the only way to do it is via a programmatic registry edit, print, then change the registry back. Is this the only solution? If so, can anyone help with the correct way to do t...