winforms

Override OnPaint

If I override OnPaint and draw a square on the control, how do I get that e.graphics.draw... to show up when I'm previewing it in the designer? ...

How can a UserControl destroy itself?

When the user clicks on certain part of a window, I add a UserControl to the window's controls. The UserControl has a close button. What can I do in the UserControl's button handler to destroy the UserControl? There seems to be no .net analog to the Win32 DestroyWindow call, and there is no Close() method for a control. So far I have thi...

How do I refactor a WinForms application?

I'm going to bugfix a WinForms application (.NET 2.0) in the near future. Looking through the source code I find large code files (more than 2000 lines) most of them are generated dialogs with lots of code-behind. Has anyone tips for me to share? Any war stories or best-practices for bug fixing or refactoring WinForms applications? ...

Applying a DataGridViewComboBoxCell selection change immediately

When I change a value in a DataGridViewComboBoxCell the new value is not immediately applied until that cell leaves focus. Is there a way to have the new value applied immediately? ...

Best Way to Horizontally AutoSize a WinForms TreeView Control?

Hello, I have a treeview control in WinForms that is filled from a wide variety of database content. I need to calculate the minimum width of the treeview control (after it is populated) so that horizontal scroll bars are not necessary to view the content. The calculation needs to account for the size of the longest text in the tree b...

How can I tell at run-time which control is in front?

I have a container control (a Panel) that has a number of Forms loaded into it. Based on user interaction, I .BringToFront() certain forms. However, in other parts of the program, I would like to figure out which form is currently in front. (In other words, determine which was the last form to have its .BringToFront() method called.) Wh...

Ready-made animation libraries

I am looking for some progress animations to be shown in my WinForms application - so anything like AVI or animated GIF will do. The best would be animations depicting some "abstract" concepts, such as (for example) flying paper or animated 0s and 1s, to indicate progress. I know that Visual Studio 2008 comes with its own animation libr...

What's the best method to switch between forms in C# ?

What's the best method to switch between forms in C# ? Scenario: I want to click a button in a Form1, kill the existing Form1 and create Form2. How can I achieve this ? I would much appreciate it, if someone could even compare the complexity of this task in Winforms vs WPF. ...

Can I download files from a folder with a Password?

Hi All, t get a password to enter,this folder get a password (of course i insert the password ) because its deny access and to be canceled from person without permission so i'm looking how download files from that folder with C# . Before i tried to download files but Visual Studio got an error: "Access Denied"! Do you have any advice ...

How to Implement Custom Windows Forms Designer ?

How can we implement Windows Forms Designer in a WinForms application ? Visual Studio uses System.ComponentModel.Design namespace to implement the Form Designer. How can we use this to implement a Form Designer in a WinForms application ? Is there any other library available for achieving the same ? ...

WinForms: two way TextBox problem

I have a TextBox, which I use for both data input and display. A user can select items from a list and for each item there is a corresponding text which is displayed in the TextBox when the item is selected. The user can edit this textbox, thus changing the list item's correponding text. My problem is this: I use the TextChanged event ...

WinForms: temporarily disable an event handler

How can I disable an event handler temporarily in WinForms? ...

Where is Message defined in .Net, using the Compact Framework?

Should be an easy question, so don't all pile on - I'm trying to override WndProc like this: using System; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; snip... public class GTextBox : ...

Can I target a browser instance from a winforms application?

We are trying to do a loose-integration of our product with another in the company. Ours has both a windows and web client, theirs is entirely on the web. In short they've made a landing page for us that accepts some parameters and we simply make a GET to that URL to transition the user into the other application. There are issues in th...

Close tab on winforms tab control with middle mouse button

Is there any easy (5 lines of code) way to do this? ...

F# and winform Controls Question

I am very new to F#, and I thought I would develop a simple winform calculator to strengthen my skills with F# and .NET. I ran into two problems which probably have very simple answers, however, I could not find any assistance from my resources. First, I want to be able to change my textbox type to integer, so that when I press my "add...

How to extend the VisualStudio Form designer

I would like to write an extension to the VisualStudio form designer which automatically corrects some properties of controls: More specifically, I would like to be able to select a TableLayoutPanel, invoke some command (menu, macro, verb, whatever) and have the AutoSize, Anchor, Margin, Padding etc. properties of the contained controls...

How to Create Collapsible Data Grid?

How to Create Collapsible Data Grid in dot net windows form application? ...

DataGridView bound to DataTable. Getting comboboxes for enums.

If you have a DataTable that has a column of some Enum type. And you bind a DataGridView to this DataTable (myDgv.DataSource = myDataTable).. How can you make the DataGridView show a combobox (or is it drop-down-list? The one where the only thing you can do is select) in each cell of for this column? The combobox should have the curren...

WinForms - How do you get the size a Control "wants" to be?

When a Control is docked in a container (like a Panel) and is too wide to be shown (so a scroll bar appears), Control.Width seems to return the visible width of the Control (the top arrow in the picture). How do you get the width that the Control "wants" to be? i.e. its full width that you'd see if you didn't have to scroll (the bottom ...