winforms

Unexpected Cross Thread Exception

The following method is launched from the constructor of UserControl. A cross thread exception is thrown, but I can't tell why: public override void Populate() { base.Populate (); LoadEditableList(IEditableList); ThreadStart fix = null; fix = delegate() { if (InvokeRequired) { Invoke(fix); } else { b...

Ubiquitous way to get the root directory an application is running in via C#

My application requires that I have access to the file system. Regardless if the code runs on a web server or a console app, how can I get the root directory the application is running in. Something like C:\TheApplication... Thanks! ...

WebBrowser control resource leak

I'm working on a .NET application that loads web pages using multiple WebBrowser controls. There are several threads and WebBrowser controls involved (this is a server application), each thread creating a WebBrowser control and running a message loop for it. My question/issue is related to the WebBrowser control. Every time a web page i...

How do EventArgs Cancel work in the FormClosing Event?

How does the e.Cancel event work in the FormClosing event on a WinForm? I know you set it to True to cancel the closing, but at what point does the form process this? Is there a secondary action taken by the property? How could I implement a similar action in a custom control? (C# or VB) Note: I've looked for about 30 minutes now and ...

C# Mouse Right Click and Control Focus

I have a form which users can add controls to and when they right click it brings up a context menu which has an option to display the properties of the control they right clicked on. The problem I am having is trying to decide how to find out what control the user right clicks on since it could be any number of them and then giving tha...

Winform not rendering control alterations

Hi All :) I've created a winform in c#, I have 3 controls on the pages and another control and is created programmatically on one of the original controls. It's not rendering, so I Changed the background colours of the other controls (they are all bright colours to begin with) and when I run the app the changes have not taken place, I'v...

UI Editor for .NET application

I need .NET UI control that acts as a designer/editor window similar to what you see in some of these applications: - Visual Studio - Visio - Balsamiq - Windows Workflow - Photoshop I hope to use WPF, but will settle for WinForms. I need to create custom widgets that I can drag, drop, and edit in the designer/editor window. I ...

What font and size is used in Windows 7 File Explorer Tree

I am having a hard time to find out which font is used by the Win 7 File Explorer in the tree view on the left hand side. Better, of course, would be if I can programmatically find out which the right font is (C#). I searched the Windows 7 design guidelines but this particular scenario is not listed (at least I couldn't find it). So an...

Adding GUI components to a precompiled application.

iI there any way to add a GUI component to an application which is already running? I.E. Add an extra tab into a third party GUI? I have a third party application where I need to add an extra tab into the tabbed interface (or even a button to link to a new form). I can see the UI components in UISpy and Spy++ but Can't see a way to al...

PInvoke.net is nice but where do I get good examples and information relating to usage of Win32 in .net apps?

Stuff like this and this is very nice and to some extent is representative for the information I am generally looking for. I found that using Win32 functionality in C# winform projects is possible and, when used wisely, can provide a much enhanced user experience. Sadly, information on MSDN can be scarce at best and almost never offers d...

Binding a Dictionary to the DataGridView in C#?

I have a dictionary item as below Dictionary<string, List<StrikePrice>> where public class StrikePrice { public string Strike { get; private set; } public string Price { get; private set; } public StrikePrice(string strike, string price) { Strike = strike; Price = price; } } and I wish to assign...

Stuck with datagridview and combo box column

I have a typical requirement. I have a datagridview with a combobox column(items loaded at design time). When a user selects an item from combobox, remaining rows gets updated in database based on the selectedItem and dgv gets refreshed. Problem is the combo box will lose its current selection and goes to unselected state. I want to re...

Login name should appear in the textbox?

Using VB.NET Windows Based Application In my software I am using a login page, with a textbox for username. First time am entering the username and password in my software, next time I run my software the last entered username should automatically appear in the login page. In VB.net, How to do this? ...

GridView Size Problem?

Using VB.NET 2008 Am using Datagridview in my application, Datagridview should display according to the windows screen size, Before I used vb6 code. Private Sub Form_Resize() On Error Resume Next If Me.WindowState = vbMinimized Then Exit Sub End If listview1.Top = 1550 listview1.Left = 0 If ScaleHeight >...

Windows 7 Jump-List (Windows Forms, C#)

Hello, Does anybody know how to customize the Windows Jump-List feature related to my own application in C#? I know it can be done, but I cannot find anything C#/Windows7 related on MSDN yet. The only info related to W7 and C# I can find so far is just compatibility junk which I've already read. Thanks all Baeltazor ...

How to trap delete row ( from keyboard ) in datagridview?

Background I have a custom collection that is binded to the datagridview this.datagridview.DataSource = mycollection I have a delete button on the user interface . User can click on the delete button to delete the selected DX Directory. Some entried cannot be deleted so I Enable and Disable "delete button". It works fine in case use...

Cancelling databound control validating event doesn't suppress attempt to update data source. winforms, .net

I'm not getting the behaviour I would expect for a TextBox bound to an integer property in a business object. Here's what I did: (1) Set the DataSourceUpdateMode, for the TextBox to: OnValidation. (2) In the Validating event for the TextBox, set e.Cancel = True if Integer.TryParse fails. (3) Add a handler to Binding.Parse and Binding...

How do I reliably detect when the mouse leaves a control?

I have a number of controls with ToolStrips containing buttons. I need to show or hide some of the buttons when the mouse enters the toolstrip. I know Mystery Meat is bad but it's what I've got to do. The ToolStrip's MouseEnter event fires when the mouse enters, but MouseLeave does not always fire when the mouse leaves. I think this ma...

Check Installer Permissions with Windows Visual Studio 2008 C#

Lots of Installer questions, but I can't find the answer to what I want. I've got an installer that can log in an Administrator account to continue the setup, but I don't know how to check the current user to see if he/she already has Administrator or Power User privileges. How can I check to see what kind of permissions the curren...

Winforms: Best control to use for listing data quickly

I need a control that can list data in 3 columns, I want to manually add the items (not databind the control)..... firstly I'll populate column 1 and 2, then later when a button is clicked, I need to loop through the values of column 1 and 2, perform an operation, then update the value of column 3. From what I remember the datagrid d...