winforms

Displaying Flash content in a C# WinForms application

What is the best way to display Flash content in a C# WinForms application? I would like to create a user control (similar to the current PictureBox) that will be able to display images and flash content. It would be great to be able to load the flash content from a stream of sorts rather than a file on disk....

Looking for a MVC Sample for WinForms

Can you point me to a good real-world WinForms MVC application/framework? I understand the Model part - that's your data, and I know the forms are the views, but what's the controller? Especially if I want to use data binding....

Global Exception Handling for winforms control

When working on ASP.NET 1.1 projects I always used the Global.asax to catch all errors. I'm looking for a similar way to catch all exceptions in a WinForms user control which ends up being a hosted IE control. What is the proper way to go about doing something like this? ...

How should I translate from screen space coordinates to image space coordinates in a WinForms PictureBox?

I have an application that displays an image inside of a WinForms PictureBox control. The SizeMode of the control is set to Zoom so that the image contained in the picture box will be displayed in an aspect-correct way regardless of the dimensions of the PictureBox. This is great for the visual appearance of the application because you...

Possible to "spin off" several GUI threads? (Not halting the system at Application.Run)

My Goal I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm not sure this is even possible with Windows Form...

How to render a control to look like ComboBox with Visual Styles enabled?

I have a control that is modelled on a ComboBox. I want to render the control so that the control border looks like that of a standard Windows ComboBox. Specifically, I have followed the MSDN documentation and all the rendering of the control is correct except for rendering when the control is disabled. Just to be clear, this is for a s...

How to make a button appear as if it is pressed?

Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button look "pressed"? Imagine this button is an on/off switch. ToolStripButton has the Checked property, but the regular Button does not....

Print a Winform/visual element

All the articles I've found via google are either obsolete or contradict one another, what's the easiest way to print a form or, say, a richtextbox in c#? I think it's using the PrintDiaglog class by setting the Document, but how does this get converted?...

Should I provide accessor methods / Getter Setters for public/protected components on a form?

If I have .Net Form with a component/object such as a textbox that I need to access from a parent or other form I obviously need to "upgrade" the modifier to this component to an Internal or Public level variable. Now, if I were providing a public variable of an int or string type etc. in my form class I wouldn't think twice about using...

How do I make event callbacks into my win forms thread safe?

When you subscribe to an event on an object from within a form, you are essentially handing over control of your callback method to the event source. You have no idea whether that event source will choose to trigger the event on a different thread. The problem is that when the callback is invoked, you cannot assume that you can make upd...

How to programmatically iterate datagrid rows?

Hi, I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an ArrayList of business objects bound to a Windows Forms DataGrid. I'd like the user to be able to edit the cells, and when finished, press a Save button. At that point I'd like to iterate the al...

Best way to access a control on another form in WinForms?

First off, this is a question about a desktop app using Windows Forms, not an ASP.Net question. I need to interact with controls on other forms. Trying to access the controls by using, for example, the following... otherForm.Controls["nameOfControl"].Visible = false; ...doesn't work the way I would expect. I end up with an exception ...

HTML Email Editor in a Windows Forms Application

We are looking for a WYSIWYG editor control for our windows application (vb.net or c#) so that users can design HTML emails (to send using the SMTP objects in the dot net framework) before sending. Currently all the available editors we can find have one of the following issues: a)They rely on mshtml.dll or the web browser control whic...

"Could not find type" error loading a form in the Designer

I have a .NET 2.0 windows forms app, which makes heavy use of the ListView control. I've subclassed the ListView class into a templated SortableListView<T> class, so it can be a bit smarter about how it displays things, and sort itself. Unfortunately this seems to break the Visual Studio Forms Designer, in both VS2005 and 2008. The pr...

Compact Framework/Threading - MessageBox displays over other controls after option is chosen

I'm working on an app that grabs and installs a bunch of updates off an an external server, and need some help with threading. The user follows this process: Clicks button Method checks for updates, count is returned. If greater than 0, then ask the user if they want to install using MessageBox.Show(). If yes, it runs through a loop an...

In WinForms, why can't you update UI controls from other threads?

I'm sure there is a good (or at least decent) reason for this. What is it? ...

HowTo Disable WebBrowser 'Click Sound' in your app only.

The 'click sound' in question is actually a system wide preference, so I only want it to be disabled when my application has focus and then re-enable when the application closes/loses focus. Originally, I wanted to ask this question here on stackoverflow, but I was not yet in the beta. So, after googling for the answer and finding only ...

Why do I get the error "Unable to update the password" when calling AzMan?

I'm doing a authorization check from a WinForms application with the help of the AzMan authorization provider from Enterprise Library and I'm receiving the the following error: Unable to update the password. The value provided as the current password is incorrect. (Exception from HRESULT: 0x8007052B) (Microsoft.Practices.EnterpriseLi...

Future proofing a large UI Application - MFC with 2008 Feature pack, or C# and Winforms?

My company has developed a long standing product using MFC in Visual C++ as the defacto standard for UI development. Our codebase contains ALOT of legacy/archaic code which must be kept operational. Some of this code is older than me (originally written in the late 70s) and some members of our team are still on Visual Studio 6. However,...

Can you use generic forms in C#?

You should be able to create a generic form: public partial class MyGenericForm<T> : Form where T : class { /* form code */ public List<T> TypedList { get; set; } } Is valid C#, and compiles. However the designer won't work and the form will throw a runtime exception if you have any images stating that it cannot find the ...