winforms

Is there a way to prevent WinForms controls in a WPF window from being unstyled?

I have some WinForms controls that I need to use in a WPF window. I'm able to get the controls to show up just fine and everything works as I would expect, but I'm experiencing one issue: all the WinForms controls are unstyled. I'd like for the WinForms controls to at least use the default OS style (like I would see in a WinForms applic...

Adding an Array of labels to a Panel

I'm trying to add an array of labels to a panel in my Form. I chose a label because I could set colors for the text. If there is a better way, please let me know. The code below runs fine but will only display one label. I set a breakpoint and looked at the array before adding and all the elements are there. However, only one label ac...

How do I write an async class with a minimal amount of repeated code?

Hi, how do i write a async class like WebClient? Is there anyway i can keep it short and does not have to repeat it for every method? for example, i have: Download(string a) Download(string a, string b) do i have to rewrite Async + Complete method for each of these? Thank you very much. ...

C# Propertygrid default value typeconverter

I have a propertygrid with a dropdown box. In my application a user can click on a block and then the properties of that block are shown in a propertygrid. But the first time they click on a block an invalid value (0) is shown in the dropdown. How can I make sure that a valid value is shown? Here is some code of the TypeConverter: publ...

How to prevent rows in datagrid from flickering while application is running

In the application I'm developing at the moment I'm using a datagridview to display data. To fill it, I've to press a button and a backgroundworker will start running, it will fill a datatable and when it's finished running it will use the datatable as the datasource for the datagrid. This works fine, the UI stays responsive et cetera. B...

Is a form Disposed when the user closes it from window bar/etc.

Is a System.Windows.Forms.Form automatically disposed when the user closes it with the top right X, or Alt+F4 ? The form is shown with form.Show(this), not form.ShowDialog(...); ...

How to select multiple files with an OpenFileDialog?

I have a WinForms application with an OpenFileDialog in it and I'd like to enable selection of multiple files when the user interacts with the dialog. How can I accomplish this? ...

.NET Is it possible to have a contextmenu on an item of a combobox?

In my application I have dropdown list with several items. I'd like to show a context menu when the user clicks the right mouse button on a dropdown item. Is this possible? And if it is possible, how? ...

How to uniquely Identify windows forms ?

My application needs to identify every form of every opened application. For example, if i press "Ctrl+f1" when i am in any application(lets say microsoft outlook), and if i am in the "new message" form, i need to send a message to my application with the following information: process=outlook.exe form="new message" form id? (or whate...

Winform Save file dialog - localization override

My winform application UI is in English. No localization is supported. When i use the OpenFileDialog dialog, it appears with a language as the hosted OS. I'd like to keep all dialogs in my app to be in english no matter what the hosting OS language is. i tried to add this at the init of my app: Thread.CurrentThread.CurrentCulture = new...

Shortcut keys defined in .LNK files do not work if I'm running a C# WinForms program that has no border and it it maximized

To test this problem I wrote a simple C# program, using .NET 2.0 and WinForms and Visual C# 2008 Express. I'm using Windows 7 but the problem is also under Windows XP. Important: the FormBorderStyle property of the main form is set to None, and the WindowState to Maximized. The program does nothing special. When this program is running...

DataGridView row is still dirty after committing changes

DataGridView.IsCurrentRowDirty remains true after I commit changes to the database. I want to set it to false so it doesn't trigger RowValidating when it loses focus. I have a DataGridView bound to a BindingList<T>. I handle the CellEndEdit event and save changes to the database. After saving those changes I would like DataGridView.I...

Adding Editor / EditorAttribute at Run-time (Dynamically) to an Object's Property

How to add the EditorAttribute (Editor) to an object's property at run-time? I have My.Settings.ExcludeFiles, which is created by the settings designer as Public Property ExcludedFiles() As Global.System.Collections.Specialized.StringCollection. When editing ExcludedFiles via a property grid, the "String Collection Editor" generates a "...

C# drawing in layers

I have an idea and maybe you guys can give me a good start or an idea in which path might be correct. I have a picturebox right now loading a specific bmp file. What I want to do is load this bmp file into the picturebox and then load another picture on top of it. The kicker to this all is the 2nd picture must be drawn. The 2nd pictu...

How to convert enum to a bool for DataBinding in Winforms?

Is it possible to do this? I need to use: this.ControlName.DataBindings.Add (...) so I can't define logic other than bind my enum value to a bool. For example: (DataClass) Data.Type (enum) EDIT: I need to bind Data.Type which is an enum to a checkbox's Checked property. So if the Data.Type is Secure, I want the SecureCheckbox to ...

C# Databound winform control does not retain value unless you leave the field

I saw the answer in http://stackoverflow.com/questions/1060080/databound-winforms-control-does-not-recognize-change-until-losing-focus But this doesn't fully answer the question for me. I have the exact same situation. On ToolStrip_click, I go through all of my controls and I force "WriteValue()", but it still reverts to the previous v...

Sorting Datagridview's Column by text and not value

I have a column in my datagridview that is a combobox column. I would like it sorted by it's display value (i.e. text) instead of it's value (in this case, a list of int's from the database). How can I do this? ...

how to show the hour & minutes on the DateTimePicker in C#

hello, I'm using C# .NET and I have a Windows Form with a DateTimePicker. My question is: who can I display on the form the hours and the minuts (to choose) along with the year, mounth and day? thanks! ...

System Tray notifyIcon won't accept left-click event

Hi, I'm creating a System-Tray only application. It's somewhat complicated to have the icon without a main form, but through previous topics on StackOverflow I've worked it out. The right-click works fine, I've linked in a context menu, etc. I'm having problems with the left-click. As far as I can tell, the "notifyIcon1_Click" event isn...

Menu Contols like the Office 2007 Ribbon

Is there a way to my WinApp written in C# using Visual Studio 2008 have menu controls which look like on these We can fund in Office 2007. ...