winforms

How to simulate windows shutdown while debugging?

I have an issue with my application when windows shuts down - my app isn't exiting nicely, resulting in the End Task window being displayed. How can I use the debugger to see what's going on? e.g. is there a way to send the windows shutdown message(s) to my application so it thinks windows is shutting down, so i can see exactly how it b...

How to set DataGridView column properties for automatically generated columns?

I edit data in a DataTable which is bound to a DataGridView. When a new column is created in the DataTable a new column is generated in the view. Ordinarily I would set the view column properties in a DataGridView_ColumnAdded event, however the default for the columns at present is to add a view column with SortMode set to Automatic whi...

Why does my application not close on logoff/shutdown (c#/.net winforms)?

My winforms app isn't shutting down nicely when I log off/shutdown. I have a main form, whose Closing event is fired correctly, but there must be something else keeping my application around. If I check Application.OpenForms there's just my one main form. The tricky bit, and where the problem probably lies, is that my application uses S...

GDI+ exception saving a Bitmap to a MemoryStream.

I have a problem in a Windows Forms application with Bitmap.Save failing when I save to a MemoryStream. The problem only seems to occur intermittently on one machine (so far) and the bad news it is at a customer site. I can't debug on the machine, but I got a stack trace that narrowed the problem down to a single line of code. Here's ...

Hide form at launch

Hello! I have a program which only needs a NotifyIcon to work as intended. So I've been trying to get the main form to hide when the program starts. In frmMain_Load, I tried both this.Hide(); this.Visible = false; without success. They work in other methods, like in the NotifyIcon_MouseClick-method, but I want it to hide at Load. I...

Caching strategy

i have a large list of static data from a server that i load on startup. I load this into a hashtable of foo objects. the user has a dropdown where they can choose one of these object. by default there are 50,000 objects which take up a lot of memory. i am trying to reduce memory after monitoring usage, it turns out that most people o...

Windows style text editor for .NET

Can you guys recommend a Windows style text editor control for a .net winforms application? Under $100 preferably. ...

Microsoft Visual Studio License

I developed a small winforms application for myself in Microsoft Visual Studio 2008 Professional Edition at my workplace, the Visual Studio is licensed to the firm I work at. If I want to sell that application, what are my license options? EDIT: The issue here is not my relationship with my employer (the code was written after hours, w...

Creating an installer for updated WinForms app

I released an app and I've implemented a user-requested feature and would like to release a new version. I'm not sure how this is typically done - is there some setting in the .NET setup project that I can use to tell it to just overwrite certain files if the application is already installed, or do I have to generate a patch somehow? I...

a problem with GUI using C#

Dear all at the begining of my application i disable some buttons and according to some conditions these buttons became enabled. my problem is when the user clicks on a button then it does my action its color becomes gray and that when i make it disabled again. for more explanation: button.Enabled = false; if(Condition) { button.enabl...

Controls on an MDI parent background

Is it a good idea to place controls on the background of an MID parent window? I've added a split container to the MDI window which displays as expected however when I try to open any other forms in the same window they show BEHIND the SplitContainer. The only way to get them to popup is if I use ShowDialog to display them. Unfortunately...

How to diff changed form file - ( .Designer InitializeComponent )

Using Suversion and WinDiff its no problem to branch / merge class-projects and web-projects. The only kind of project I can never merge are winform projects. The InitializeComponent method is always scrambled after only little changes. Is there any good way to enable diff / merge for .Designer - files? EDIT: I used a 3 way diff lik...

How do I change the cursor for a ToolStripButton?

I want to change the user's cursor when they hover over a specific ToolStripButton, but not for the other items on the ToolStrip. How do I set the button's cursor? ...

Keep UI Thread free

Hi guys, I have a form with two panels(top, bottom), each panel contains grids. Basically, it's a Master-Detail form where selecting a row from the top grid would show details in the bottom grid. Binding the data to the detail grid is taking some time. Since binding is done on UI thread, it blocks the thread and therefore the user can...

.NET WinForms and the enterprise library validation application block

I have a TextBox whose value is passed to an int property in an object after being parsed to an int. When I use a ValidationProvider this conversion step is ignored when validating and I get an error telling me that I cannot save the string to an int32. I can fix this by creating a string property in my object that acts as a bridge bet...

Easiest way to format rtf/unicode/utf-8 in a RichTextBox?

I'm currently beating my head against a wall trying to figure this out. But long story short, I'd like to convert a string between 2 UTF-8 '\u0002' to bold formating. This is for an IRC client that I'm working on so I've been running into these quite a bit. I've treid regex and found that matching on the rtf as ((\'02) works to catch it,...

Is it possible to display a message in an empty datagrid

I have a datagrid which is populated with CSV data when the user drag/drops a file onto it. Is it possible to display a message in the blank grid for example "Please drag a file here" or "This grid is currently empty". The grid currently displays as a dark grey box as I wait until the file is dragged to setup the columns etc. ...

How do you prevent the Visual Studio designer auto-generating columns in a DataGridView?

I generate all my columns in a subclassed DataGridView programmatically. However Visual Studio 2008 keeps reading my constructor class (which populates a DataTable with empty content and binds it to the DataGridView) and generates code for the columns in the InitializeComponent method - in the process setting AutoGenerateColumns to false...

Creating a Designer similar to the UserControlDocumentDesigner

I would like to create a Designer that will allow me to add controls during runtime to a custom control, just like the System.Windows.Forms.UserControl. I noticed that the UserControl uses the UserControlDocumentDesigner, because this is internal i cannot use it. So i will implement my own. public class MyDesigner : DocumentDesigner {...

How do I get a disabled ToolStripButton to paint its image in colour?

We have a button which allows users to 'lock' a form. Users are not permitted to 'unlock' the form, so when pressed, we want the button to be disabled, so that the user receives appropriate visual feedback. However, the customer reports that the greyed 'lock' icon suggests to them that the form is not locked, so we would like to displa...