winforms

Shape of a Winforms MessageBox

I am looking for a way to have some control over the shape of a simple MessageBox in Winforms. I would like to control where the passed in text wraps so that the dialog rect is narrower. Windows seems to want to make the dialog as wide as possible before wrapping the text. Is there an easy way to control the maximum width of the dialog w...

What's the right way to dynamically choose menu items for a context menu in WinForms?

I'm trying to make a context menu for a control that is "linked" to a main menu item. There are two fixed menu items that are always there and an arbitrary number of additional menu items that might need to be on the menu. I've tried solving the problem by keeping a class-level reference to the fixed menu items and a list of the dynami...

How to render unicode characters in the correct font? (C#/WinForms)

My application correctly handles different kind of character sets, but only internally - when it comes to displaying text in standard WinForms labels und textboxes, it seems to have problems with chinese characters. The problem seems to be the font used (Tahoma), because when I copy&paste the text, or view it in the debugger, it is disp...

Winform application profiling CPU usage / spikes . .

I have a winforms application that normally is at about 2-4% CPU. We are seeing some spikes up to 27% of CPU for limited number of times. What is the best profiling tool to determine what is actually causing this spike. We use dottrace but i dont see how to map that to exactly the CPU spikes? Appreciate the help ...

How to record window position in WinForms application settings

It seems like a standard requirement: next time the user launches the app, open the window in the same position and state as it was before. Here's my wish list: Window position same as it was Unless the screen has resized and the old position is now off screen. Splitters should retain their position Tab containers should retain their...

How do I Yield to the UI thread to update the UI while doing batch processing in a WinForm app?

I have a WinForms app written in C# with .NET 3.5. It runs a lengthy batch process. I want the app to update status of what the batch process is doing. What is the best way to update the UI? ...

How to make sure a font exists before using it with .NET

I have a VB.NET Windows Forms project that at one point paints text directly to onto the form at runtime. Before I paint with the font though, I want to make sure that the font and font-size exists on the user's machine. If they don't, I'll try a few other similar fonts, eventually defaulting with Arial or something. What's the best way...

How to draw custom button in Window Titlebar with Windows Forms?

How do you draw a custom button next to the minimize, maximize and close buttons within the Titlebar of the Form? I know you need to use Win32 API calls and override the WndProc procedure, but I haven't been able to figure out a solution that works right. Does anyone know how to do this? More specifically, does anyone know a way to do ...

How can I get the filetype icon that Windows Explorer shows?

Hi all, first question here. I'm developing a program in C# (.NET 3.5) that displays files in a listview. I'd like to have the "large icon" view display the icon that Windows Explorer uses for that filetype, otherwise I'll have to use some existing code like this: private int getFileTypeIconIndex(string fileName) { s...

Subclassed form not behaving properly in Designer view (VS 2008)

I have subclassed Form to include some extra functionality, which boils down to a List<Image> which displays in a set of predefined spots on the form. I have the following: public class ButtonForm : Form { public class TitleButton { public TitleButton() { /* does stuff here */ } // there's other stuff too, just ...

VB.NET - RichTextBox - Apply formatting to selected text.

Hello, this may be n00by, but, I have this simple question: I have a RichTextBox control on my form. I also have this button, labeled Bold, that I want, if someone selects text in the RichTextBox, then presses the button, the selected text turns bold. Any way to do that? Simple, everyday task for end users. Thanks. ...

WinForms context menu - not open in certain parts / detect underlying control

Hi all, I have a .NET 2.0 Windows Forms application. On this app there is a Form control with a Menu bar and a status bar. Also there's a ListView on this form. If I add a context menu to this form, the context menu will open when the user right clicks any part of the form, including the menu bar and the status bar. 1) How can I prev...

Reading datagridview

I populated a datagridview from a datatable. How do I read from the datagridview when the application is running? ...

What are the bigger hurdles to overcome migrating from Winforms to WPF?

I've been developing Winforms applications in C# for a few years now and have been interested in moving future development toward WPF, mainly because of the positive things I've been hearing about it. But, I'm wondering what sort of hurdles others have had to overcome as they migrated to WPF. Was there a significant hit to your product...

Limiting a group of checkboxes to a certain amount of checks

I have a group of checkboxes that I only want to allow a set amount to be checked at any one time. If the newly checked checkbox pushes the count over the limit, I'd like the oldest checkbox to be automatically unchecked. The group of checkboxes all use the same event handler shown below. I have achieved the functionality with a Queue, ...

Anyone familiar with a good "sticky windows" library for Winforms?

I want to recreate the stickiness and snapping of windows, like it is implemented in Winamp. The basic premise is, when you drag a window and it comes close to another one, it will snap to it and will stick. When you move it the two will move together. I need it for a MDI application. ...

Debugging Designer processing in VS 2008

I have a public property set in my form of type ListE<T> where: public class ListE<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable Yeah, it's a mouthful, but that's what the Designer requires for it to show up as an editable collection in the Properties window. Which it does! So, I click the little [..] ...

How can I make a Enso style application in C#

The background should be transparent, but the text should not. ...

How do you "preview" user actions like resize or editing in GoDiagrams?

The GoDiagram object model has a GoDocument. GoViews have a reference to a GoDocument. If the user does any modification on the diagramming surface, a GoDocument.Changed event is raised with the relevant information in the event arguments. I would like to be notified when some user-actions happen, so that I can confer with my Control...

Create program installer in Visual Studio 2005?

I'm a web-guy stuck in "application world" in VS 2005. I created my windows forms program and want to give my end users the ability to install it (and some of it's resources) into a standard Program Files/App Directory location along with a start menu/desktop launcher. The help files don't give any instructions (that I can find). Th...