winforms

C#/.NET - WinForms - Instantiate a Form without showing it

I am changing the Visibility of a Form to false during the load event AND the form still shows itself. What is the right event to tie this.Visible = false; to? I'd like to instantiate the Form1 without showing it. using System; using System.Windows.Forms; namespace TestClient { public partial class Form1 : Form { public...

ComboBox bound to an enum type's values while also having a "blank" entry?

If I bind a WinForms ComboBox to an enum type's values, i.e. combo1.DropDownStyle = ComboBoxStyle.DropDownList; combo1.DataSource = Enum.GetValues(typeof(myEnumType)); Who knows how I could achieve the same result, while, in addition to entries matching each enum value, I can also have a blank entry representing no selection? I canno...

Methods to find the visible area of a Windows.Forms component immediately?

I hate it when I try to apply some logic to positioning elements on a form, only to have the rug jerked out from under me because of some bizarre gotcha like the visible area of the Control being affected by a Border which, in effect, creates a 3 pixel margin all around the inner, visible area of the Panel, and completely throws off any ...

3rd Party WinForm .NET Grid Controls

Anybody have any experience with 3rd Party WinForm .NET grid controls? Before I spend the afternoon downloading and trying out several of the grids and/or control packs, anybody have opinions on vendors? functionality? etc. Some of the ones I'll be looking at are: XCeed Grid Telerik Grid - Part of RadControls for WinForms ...

WinForms Control - Action after it is fully initialized

To a WinForms control, I would like to add a handler after the container has initialized the control (or even better, after the parent has initialized all contained controls). Reason: The custom control has an option to trigger an action automatically. It should also trigger when this option is first enabled. However, at this point, ot...

How do I create a C# app that decides itself whether to show as a console or windowed app?

Is there a way to launch a C# application with the following features? It determines by command-line parameters whether it is a windowed or console app It doesn't show a console when it is asked to be windowed and doesn't show a GUI window when it is running from the console. For example, myapp.exe /help would output to stdout on the...

Fire ListView.SelectedIndexChanged Event Programmatically?

How can one programmatically fire the SelectedIndexChanged event of a ListView? I've intended for the first item in my ListView to automatically become selected after the user completes a certain action. Code already exists within the SelectedIndexChanged event to highlight the selected item. Not only does the item fail to become hig...

Editable ListView

I am looking to create an editable ListView in a C# winforms application where a user may double click on a cell in order to change its contents. It would be great if someone could provide my with some guidance and/or an example. I am not looking to use any commercial products. ...

Combine two (or more) PDF's

Background: I need to provide a weekly report package for my sales staff. This package contains several (5-10) crystal reports. Problem: I would like to allow a user to run all reports and also just run a single report. I was thinking I could do this by creating the reports and then doing: List<ReportClass> reports = new List<ReportCla...

C# Windows Form TreeView Sort after LabelEdit

After a node's label is edited in the tree I try to resort the nodes to place the updated item in the right position. I do this by calling .Sort in AfterLabelEdit event handler which causes an infinite loop. How can I resort the nodes in a treeview after a label has been changed? ...

Windows forms Text Changed on leave event

Maybe I'm just an idiot, but I can't seem to find an event that will fire for a textbox at the same time as the leave, but only when the contents of the textbox has changed. Kinda like a combination of textchanged and leave. I can't use textchanged cause it fires on each keystroke. Right now I'm storing the current value of the textbo...

Invoke or BeginInvoke cannot be called on a control until the window handle has been created

I have a SafeInvoke Control extension method similar to the one Greg D discusses here (minus the IsHandleCreated check). I am calling it from a winform as follows: public void Show(string text) { label.SafeInvoke(()=>label.Text = text); this.Show(); this.Refresh(); } Sometimes (this call can come from a variety of threads...

How to grab attachment programmatically (C#) from a POP3 mail?

Is there any C# API for this task? Any suggestions? ...

winforms: How to send email using default email client?

I want to send an email from a .net windows forms application using the system's default email client (thunderbird, outlook, etc.). I'd like to preset the subject and body text -- I think there's a way to do this by sending something like this to windows explorer: "mailto:[email protected]?subject=mysubject&body=mymessage". Do you hav...

Multiple MouseHover events in a Control

I'm trying to implement a custom control in C# and I need to get events when the mouse is hovered. I know there is the MouseHover event but it only fires once. To get it to fire again I need to take the mouse of the control and enter it again. Is there any way I can accomplish this? ...

Using C# WinForms Designer on Panel instead of Form Again?

I have the same question, but the answer to use a UserControl will not do. I also need to create a control container that I can add other controls to at design time so I can add it to yet another container (Splitter Panel) which is not avaialable to me at design time (plugin architecture). When I make a User Control, it is missing the...

Split Containers without too many HWNDs

I need to arrange a few of my controls using split containers such that one split container is nested inside another. I find that each instance of the SplitContainer class is itself a Control and comes with two instances of SplitterPanel which is a control too. For example, in the following illustration, I am arranging just 3 of my cont...

Parent/owner of a Winforms component

From a custom Winforms component that is embedded in a form, how to I get the parent/owner control? I have an IContainer and the Site property is not null, but I have no idea how to get to the "real" parent. (this is a followup to this question, atm I am trying to add a handler to the parents VisibleChanged, but that's not the first t...

How do I open a file using the shell's default handler?

Our client (a winforms app) includes a file-browser. I'd like the user to be able to open the selected file using the shell's default handler. How do I do that? I've read that I should use the Win32 API rather than the registry, but I'd prefer a solution that involves only .NET. ...

C# DataGridView AutoSizeRowsMode Problem

I have a DataGridView which I add data to programatically. I have the AutoSizeRowsMode set to AllCells and the WrapMode on RowsDefaultCellStyle set to True. If I add a multiline row to the DataGridView it shows up fine (autoscaling the row to show the multiple lines). However, if I hide the column that has the multiline data (so that the...