winforms

Display a map in a Windows Form app

I built a Winform app several months ago that schedules appointments for repair techs. I'd like to update the app by adding a map for the customer's address on the customer form, and then print that map on the report the techs take when they leave the office. I've been looking around but I haven't found a good solution for this yet. I ...

Is there a BeforeUpdate for a C# ComboBox on a Winform

I come from the VBA world, and remember there was a BeforeUpdate call I could make on a combobox. Now I am in C# (and loving it) and I was wondering is there a BeforeUpdate call for a ComboBox on a Winform? I can make an invisible textbox and store the info I need there and after the update, look at that box for what I need, but I was h...

Launch a URL from a WinForms app

I've got a WinForms app in which I have the need to refer the user to a web page with documentation/help. I realize the LinkButton would get the trick done, but what I want is a standard Button control to launch the system default browser when that button is clicked. The only reference code I've got for this references the Win32 API, hoo...

Reordering of controls within a flow layout panel

Good afternoon, I'm having trouble using the flowlayoutPanel in a C# winform application. What I basically have is a flow layout panel that has 3 sections. Section #1 is a set of 2 controls .. two dropdown controls, they are always in the same order, always visible in all instances Section #2 is a set of 5 different controls ... based...

How to speed up the initialization of a .net client application (winforms or wpf)?

Sometimes I create some quick personal projects using c# with windows forms or wpf. I have noticed that depending of the kind of application, looks that managed applications take 2x or 3x more time to start compared with native applications. It's does a "Quick Notes" application don't so... "quick". :-( There are some technique to spee...

Attempted to read or write protected memory. This is often an indication that other memory has been corrupted

I created a Winforms AutoComplete combobox control inheriting from ComboBox with the following method: Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs) MyBase.OnKeyPress(e) Dim text As String = Me.Text If Char.IsLetter(e.KeyChar) Then text = text + e.KeyChar ...

Waiting for messages in Managed Code

This is closely related to an earlier question. In the managed world: How do I check if the current thread has messages in its message queue? How do I yield to the OS and wait for a message in the current thread (like GetMessage or WaitMessage)? I am looking for the managed equivalents without PInvoke. ...

Slow refresh on panel scrolling

Hi, I'm developing an user control that I need for a project, the control have around 13 rows, 7 columns of textboxes, comboboxes... everything on a form autoscrollable. The problem is that in execution time when scrolling the content refreshing is very very slow. Some idea? Using a datagridview is not an option. Edit: I should be mo...

Select either a file or folder from the same dialog in .NET

Is there an "easy" way to select either a file OR a folder from the same dialog? In many apps I create I allow for both files or folders as input. Until now i always end up creating a switch to toggle between file or folder selection dialogs or stick with drag-and-drop functionality only. Since this seems such a basic thing i would im...

Is it possible to use ShowDialog without blocking all forms?

I hope I can explain this clearly enough. I have my main form (A) and it opens 1 child form (B) using form.Show() and a second child form (C) using form.Show(). Now I want child form B to open a form (D) using form.ShowDialog(). When I do this, it blocks form A and form C as well. Is there a way to open a modal dialog and only have it bl...

Winforms unceremoniously quits with "unhandled exception"

The program spits up one of those boxes saying an unhandled exception has occurred and the application must quit. The only clue I get to solve the problem is this in the event log: Event Type: Error Event Source: .NET Runtime 2.0 Error Reporting Event Category: None Event ID: 5000 Date: 1/9/2009 Time: 8:47:44 AM User: N/...

MVP and UserControls and invocation

I'm having some fun trying to get my head around some MVP stuf, as it pertains to User Controls. I'm using .NET WinForms (or something close to it) and Supervising Controller pattern (well, I think I am :). The User Control is itself part of an MVP application (its the View and has an associated Presenter etc). The Presenter is always ...

progmatically start moving a form

I am trying to make a form move (using the titlebar) from a button click. I thought this would be simple using SendMessage: Const WM_LBUTTONDOWN As Integer = &H201 Button1.Capture = False Cursor.Position = Me.Location + New Size(50, 8) SendMessage(Me.Handle, WM_LBUTTONDOWN, CType(1, IntPtr), IntPtr.Zero) However, although this send...

Creating C# winform simple dynamic controls

private void CreateNewControl() { List<Control> list = new List<Control>(); TableLayoutPanel layout = new TableLayoutPanel(); layout.Dock = DockStyle.Fill; this.Controls.Add(layout); layout.ColumnCount = 3; layout.GrowStyle = TableLayoutPanelGrowStyle...

TextBox Undo/Redo commands

The WinForms TextBox has an 'Undo' command but has not a 'Redo' command - Why? ...

What is the preferred way to find focused control in WinForms app?

What is the preferred/easiest way to find the control that is currently receiving user (keyboard) input in WinForms? So far I have come up with the following: public static Control FindFocusedControl(Control control) { var container = control as ContainerControl; return (null != container ? FindFocusedControl(container....

Thread ListBox C# SharpDevelop

Hi everyone. I'm trying to use a Thread in a simple winform. I have a ListBox which I want to fill with numbers at the form's load method. I don't want to wait until it is filled. I'm using something like this: void fillList() { Invoke(new MethodInvoker( delegate { while(true) { i++; ...

Windows Form Design-Time Error

I am using Visual Studio 2008 and I get the following error message when trying to open one of my Forms: Could not find endpoint element with name 'WSHttpBinding_ICommon' and contract 'CommonWCF.ICommon' in the ServiceModel client configuration section. This might be because no configuration file was found for your applic...

Visual Studio designer moving controls and adding grid columns when form is opened

The first time I try to open a particular form many of the controls (those with anchors on the right side and/or the bottom) are shifted and my grids automatically regain all the columns from their datasource which (the columns) I had previously removed. I have read elsewhere it is recommended to copy the 'good' designer code into the c...

C# Run Function when User Exits

Is there any way to call a function in C# when the user exists the application? I'm using Visual C# 2008 Express edition. Thanks. ...