winforms

Determining if the window is in help mode

Developing a .NET WinForms application: how can I check if the window is in Help mode (i.e. after clicking the "?" button in the title bar)? The problem I have is that my System.Windows.Forms.ToolStripItem objects do not have a HelpRequested event (because they do not inherit from Control) so in the Click event handler, I am trying to d...

How to make RightToLeftLayout work for controls inside GroupBoxes and Panels?

According to MSDN form.RightToLeftLayout = True; form.RightToLeft = ifWeWantRTL() ? RightToLeft.True : RightToLeft.False; is enough to mirrow the form content for RTL languages. But controls placement gets mirrowed only for controls immediately on the form, those inside a GroupBox or a Panel are not mirrowed, unless I put them on a ...

Regular expression to filter files in OpenFileDialog

Hi, I would like to know how to filter files in a open file dialog (in winforms) based on a regular expression. Files have all same extensions (.xml). Big files are split up into several files with the same name only to be separated with _1 ... We only want to show the files without _1 (first data file) the open file dialog has a prop...

How to set/change/remove focus style on a Button in C#?

I have a couple of buttons of which I modified how they look. I have set them as flat buttons with a background and a custom border so they look all pretty and nothing like normal buttons anymore (actually, they look like Office 2003 buttons now ;-). The buttons have a border of one pixel. However when the button gets selected (gets the...

Winforms threading problem, second thread can't access 1st main forms controls

I have a winforms application, the issue has to do with threading. Since I am calling 'MyCustomCode() which creates a new thread, and calls the method 'SomeMethod()' which then accesses MessageBox.Show(...). The problem has to do with threading, since the newly created thread is trying to access a control that was created on another th...

pitfalls/gotchas of click-once/smart-client deployment in .NET

I have several .NET WinForms applications that I'm preparing to convert into a click-once/smart-client deployment scenario. I've read the isn't-this-great tutorials but want to ask if there are pitfalls or "gotchas" that I should be aware of. there are several minor apps used off and on, but the main app is in C#, runs 24/7, is quite la...

How do I persist a ByRef variable into .net winforms dialog form?

I am creating a "department picker" form that is going to serve as a modal popup form with many of my "primary" forms of a Winforms application. Ideally the user is going to click on an icon next to a text box that will pop up the form, they will select the department they need, and when they click OK, the dialog will close and I will ha...

Implementing rulers in C# form

Does anyone have a good technique (or tutorial) to implement rulers within a C# Windows form? I want to display an image while showing rulers that indicate your mouse position to allow a more accurate positioning of the cursor. Just like the image below: I tried using splitter controls to hold the tick marks but I don't know how to ma...

Adding AutoComplete to an Infragisitcs UltraDateTimeEditor control

I'm attempting to modify an Infragisitcs UltraDateTimeEditor control so that the current year and a default time are inserted when the user only enters values for the month and day. The control has an AutoFillDate property, however setting this to "year" seems to overwrite user input entirely. Also changing the InvalidTextBehavior doesn...

Windows Forms UserControl overrides not being called

I am creating a Windows Forms control derived from UserControl to be embedded in a WPF app. I have generally followed the procedures given in this link. public ref class CTiledImgViewControl : public UserControl { ... virtual void OnPaint( PaintEventArgs^ e ) override; ... }; And in my CPP file: void CTiledImgViewControl::OnPaint( ...

What's the best way for a .NET windows forms application to update itself?

I use a home-grown system where the application updates itself from a web service. However, I seem to remember something in the original .NET sales pitch about auto-updating of components being a built-in feature of .NET. What are the best practices for having an application update itself and/or the assemblies it uses? ...

What's the best way for a .NET winforms application to update itself without using ClickOnce?

For technical reasons, I can't use ClickOnce to auto-update my .NET application and its assemblies. What is the best way to handle auto-updating in .NET? ...

.NET Winforms Deployment

Is there anyway to combine all resources into a single exe file such as app.config and associated DLL's? Some applications seem to do this such as eMule. I don't want my app.config sitting there waiting to be edited. Thanks ...

Structuring projects & dependencies of large winforms applications in C#

UPDATE: This is one of my most-visited questions, and yet I still haven't really found a satisfactory solution for my project. One idea I read in an answer to another question is to create a tool which can build solutions 'on the fly' for projects that you pick from a list. I have yet to try that though. How do you structure a very la...

If you change RightToLeft, ShowInTaskbar properties, Form.ShowDialog() unexpectedly ends.

Dialog closes with Cancel result, no exceptions, as if you have pressed its close button. The only safe place to set RightToLeft property is in the form constructor. It occured to me that this information might save somebody else's time. If you are able to elaborate on the issue: if there is an official bug confirmation, what else mig...

WinForms printing: how can I access the progress dialog?

When printing in Windows forms, or doing a print preview, a dialog is displayed with text like Page [P] of [DOC] where [P] is page number and [DOC] is the name of the document. The dialog also contains a button to allow the user to cancel the print job. How can I change the text displayed? What I would prefer is text like Page [P] ...

WebBrowser Control from .Net -- How to Inject Javascript?

I've tried this: string newScript = textBox1.Text; HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = browserCtrl.Document.CreateElement("script"); lblStatus.Text = scriptEl.GetType().ToString(); scriptEl.SetAttribute("type", "text/javascript"); head.AppendChild(scriptEl); scriptEl.InnerHtml ...

Respecting XP themes when designing WinForms UI

How do you deal with the different XP themes when designing a WinForms UI? Do you avoid hard coded color values or just accept that your UI will not look good on non standard themes? For instance, I have a light blue gradient panel that looks good against the standard control background color but would clash with other custom themes. Wh...

Mute Windows Volume using C#

Anyone know how to programmatically mute the Windows XP Volume using C#? ...

Got .PNG file. Want embeddded icon resource displayed as icon on form title bar.

This was an interview question. Given Visual Studio 2008 and an icon saved as a .PNG file, they required the image as an embedded resource and to be used as the icon within the title bar of a form. I'm looking for what would have been the model answer to this question, Both (working!) code and any Visual Studio tricks. (Model answer is ...