winforms

Icons on MainMenu/ContextMenu without losing theming

I would like to use MainMenu and ContextMenu in my WinForms app, and put icons next to some of the menu items. But MenuItem doesn't have any way to specify an icon. It would be easy to add one with owner-draw, but then my menu looks owner-drawn -- I lose all of the default drawing from the XP/Vista theme. What's the best way to get ico...

Webservice/Entity objects or datareader for my winform app?

Is it best to use a webservice to pull data from a database and load it into my entity object, then send the entity objects to my winform app? Will this make any performance difference over going direct to the database and pulling a datareader back to the winform client, then loading the entities on the client? Some of the users will b...

Load Data and show a splash screen during that

I got to load some data out of a db4o database which takes 1 or 2 seconds at the startup of my app, the rest has to wait because first of all the data has to be loaded. doing this in an own thread would mean that the rest has to wait for the thread-finishing. I'd like to do a splash screen or something during the data is loaded for what ...

'Cross-thread operation not valid' does not kill WinForms application (and it should).

Update: here is an MSDN article How to: Make Thread-Safe Calls to Windows Forms Controls. It states: The .NET Framework helps you detect when you are accessing your controls in a manner that is not thread safe. When you are running your application in the debugger, and a thread other than the one which created a control t...

Formatting Performance in Microsoft ReportViewer Control

I am building a price list ap for use in my Business (in C# 3.5 using VS 2008 and WinForms) to replace an excel spreadsheet that suffers from 15 years of trying to get it to do things excel does not do well. I am presenting the list in a ReportViewer. The report has about 650 rows and 17 columns. It loads very quickly without any condit...

Wrap text into semi-circle region

I'm modifying this glass button code to allow for both a Text and a TextExtra property. The goal is to render the Text in a larger/bolder font on the top half of the button and the TextExtra in a smaller font on the bottom half. I'm having trouble finding a good way to do this when the button is round. As written, the code uses the te...

OpenFileDialogs on C# MTAThread application.

Ok, I know that OpenFileDialogs needs STAThread, but i want to start the form from a console application, so I create a Thread for the Form that way I can print things to the console while working with the form, the problem is that if I want to use OpenFileDialogs then I can not print to the console! ...

How can I handle a windows forms datetimepicker ArgumentOutOfRangeException?

I've run into a very specific bug with the DateTimePicker control in Windows Forms. The control has a custom format (MM-YYYY -> 01/2010) - the month/year of a credit card. Today is the 29th of September. If a user selects the control, and uses the keyboard to set the month to February, the control will throw an ArgumentOutOfRangeExceptio...

Auto validation in Winforms in a dedicated label

I have seen in certain places (sorry, am unable to provide links at the moment) that validation errors in a form are displayed in a label at the top. As the user fills up the form, that error text changes accordingly. I can see an obvious if...else and handling "Validating" etc events to implement this (though it can turn out to be very...

If Form is dark, then Text on form should be Light.

Hey All, :) I have 60% Opaque form. And when the user changes the color of the form, sometimes (depending on the chosen color), they cannot see the text on the form anymore because it too-closely resembles the color of the form. So, I'm trying to do maybe an if/switch to see if the chosen BackColor of the form is either Dark, or Light. ...

DropDown list with checkboxes

How can i make a dropdown list with checkboxes ? I have a windows app ( vb.net) and the checkboxlist control is not real an option with the available space on my form. Thanks. ...

How to print a C# Windows form as a word doc would be printed?

How to print a Windows form as a word doc would be printed? I do have a windows form, the content of which, including labels and textbox values, i want to print. I did have the thought of using reports, but it would be very hard to create it, so i'm asking for a simple way of doing it (the printing). So this question popped out. Is it p...

DataGridView displays empty cells when bound to typed DataTable

I'm creating a simple application that simply populates a DataGridView with a strongly typed DataTable. My problem is that all the cells show up empty despite containing data, I have a CellDoubleClick event which can pick up the underlying value of the cell (which is typed as expected) but the column is shown as empty. Objects of type ...

.NET AnimateWindow

I am trying to make a notification window like Outlook uses when you receive a new email. I have a modeless form for the notification window with two Label controls on it to display the notification info. To get the fade-in effect, I am p/invoking the Win32 AnimateWindow function. Everything seems to be working alright except for one ...

C# Not Disposing controls like I told it to...

I have a Panel control. And inside the panel users can add combobox's, textbox's labels etc and drag them around and stuff, and there's a Delete button on my form where if they click it, it will delete all controls inside that panel. BUT this code: foreach( Control control in panel.Controls ) { control.Dispose(); } ... Does not w...

WinForms - Windows 7 and IE 8 - IE window inserts itself in between winforms app windows

Problem: Internet Explorer window steals focus from active .NET WinForms application. The open IE window acts like it gets adopted into the WinForm application so when the child window is closed from the parent Winform instead of focus going back the parent window it goes to the IE web page. However, the IE 7 window is NOT active but...

Microsoft.ExceptionMessageBox not being "found"

I have a winform solution that I deploy through clickOnce. There is the Main Project and then a Project called psWinForms. That project has a Reference to Microsoft.ExceptionMessageBox that I use in my custom error reporting. I have psWinForms as a reference in my Main Project with Copy Local = True. I have Microsoft.ExceptionMessa...

How can I take a screenshot of a Winforms control/form in C#?

I have a listview control that is on a winforms form. It fills the full screen but there are more items there than the screen can show. How can I take a screenshot of the whole control as if I could display the whole contents of the listview on screen? So if the whole listview takes 1000 x 4000 pixels, then I want an image/bitmap of tha...

RichTextBox Control in a Multi-Threaded Application

I'm using a RichTextBox control in a Windows Service to convert RTF to plain text. This method is actually mentioned by MS here: http://msdn.microsoft.com/en-us/library/cc488002.aspx My Windows Service spawns multiple threads (typically 2 x the number of CPU cores), and each of these threads ends up instantiating a separate instance of ...

Set cursor in RichTextBox

Hi, I`ve got simple form with RichTextBox on it. In Load event I write some text to RichTextBox and now I want to set cursor location to the end of this text so I can add something. I've tried Focus() but it does't work ...