winforms

How do I implement intellisense-like suggestion boxes for a winforms textbox?

We have a textbox that the user enters sets of terms into, delimited by commas and separated by newlines. There may be thousands of valid terms, so we'd like to offer the user intellisense-style suggestions as they type. The default autocomplete isn't adequate because it will only do prefix-matching on the entire textbox, and won't sup...

Trying to make a dialog window remember its last position

I am creating a simple dialogue window in C#, and want to remember where it is placed so that I can open another in the same place later (during the same application run, so no need for config files etc). I can easily save the Location (a Point) or the Bounds (a Rectangle), but on creating another form, calling form.ShowDialog() resets b...

WinForm application and MS Office references

In our WinForms project, we need to give a facility to import data from Excel sheets. There are ways to refer MS Office files (here Office 2003) in your project references. Each time there is slight difference in build environment the project reference breaks and shows an Excel missing error. My question is How to correctly refer O...

Backcolor of THE BORDER of a Windows Forms panel

Is there any way to change the BackColor of the border of a panel or similar control? I am trying to "highlight" the user control when I hover the mouse over the user control. ...

can i treat a flowlayoutpanel like a listbox

is there ways to have a selecteditem and detect when it changes. what is the recommended best practices for wanting to have listbox type behavior but i dont have strings, i have user controls that i want to list from top to bottom. is flowlayoutpanel the correct way to do this or is there any other way that gives me the listbox behavio...

DataGridView repeatedly recreating columns

I have a problem when assigning the DataSource propery on a DataGridView control. My DataSource is a DataTable's DefaultView and, as expected, columns are automatically created in the DataGridView to match those in the DataTable when I assign it. What happens next is that the columns seem to be automatically removed and recreated a furt...

Winforms listbox not updating when bound data changes

The image below shows how my code works. When I press button2 the listbox is updated, but not when I press button1. Why? Is the problem threading related? If it is, where should I add the call to (Begin)Invoke? One interesting thing to note is that if I first press button1 and then button2 the data generated by the button1 click is s...

Slow scrolling in ComboBox

Hi, I have a problem where scrolling in both a toolStripComboBox and regular ComboBox is really slow. This happens both using the arrowkeys and the mouse scrollwheel. However, if I use the scrollbar it behaves as expected. Here's the toolstrip combobox: // // toolStripComboBoxDeild // this.toolStrip...

C#: How to get the number of items in a combobox

Hello, How can i get the number of items listed in a combobox? ...

Two DataGridViews; lining up columns

The project on which I'm currently working has two datagridviews that are meant to compare two versions of similar data (same number and name of columns). I'd like to resize all the columns so that they fit two criteria: 1) Autosize to fit data (that's easy) 2) So the columns are lined up such that for any column COL, gridA[COL].Width ...

WinForm UI Validation

I need to implement input validation throughout my winform app. THere are many different forms where data can be entered and I would like to not have to go control by control by form and create isValid etc per item. How have others dealt with this? I see that most related posts deal with Web Apps and/or mention Enterprise Library Va...

How do I convert a "Keys" enum value to an "int" character in C#?

This seems like something that should be easy, but I am having a tough time figuring out what needs to happen here. In the "KeyDown" eventhandler, if the "e.KeyValue" is a number, I want to treat it as a number and store it as an int. So, if I hit "8" on the number pad, I don't want "Numpad8" I want the int value 8 that I can add or su...

Resizing a Single Control In WinForms

How might I design a UI in C#/WinForms which happens to contain several different control types such that only the ListView control gets resized if the user resizes the window? ...

Change forecolor of disabled combobox

I need black forecolor in a disabled combobox. Is it possible? ...

System.OutOfMemoryException: Out of memory (GDI)

Hello, After installing my program on a windows vista premium, I'm getting the following exception. The view that must be shown contains following controls: 2 textboxes, 3 labels, a button and linkbutton. System.OutOfMemoryException: Out of memory. at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc) at System.Windows.Forms.P...

Global event handler for all controls for User Help

HI, I'm extending a windows application written in C# to provide help to the user (in the context of the focused control) when they hit the F1 key. What I’d like to do is make use of the Control.HelpRequested event but I’m not sure how to extend all the controls to handle this event. http://msdn.microsoft.com/en-us/library/system.window...

Winforms UI feedback

Hey Everyone! I just mocked up a rough UI for a Time Management system and would like to get some feedback on it. What I am looking for in particular if I can achieve what I want to do in Winforms. Here is the mockup. http://is.gd/tH2A The area that gives me concern is the labor categories section. There could be from 1-24 different ...

Why doesn't my custom control receive drag/drop events?

I've written a custom control (an immediate child of Forms.Control) in C++/CLI that will offload most of its processing and all of its painting to a separate legacy-ish MFC control. I'm wrapping this control in a C# application. I need to be able to drag items onto the C++/CLI control from a UserControl on the same form in the applicat...

Windows XP control panel control for Windows forms

I'd like to have an application with an UI similar to Windows XP control panel. Does anybody knows of a control with the same icon view? Thanks ...

When would I need to call form.ShowDialog(IWin32Window) rather than form.ShowDialog()?

I have some code, which calls the form.ShowDialog(IWin32Window) overload rather than the form.ShowDialog() one, but which passes in the current active window as the parameter. Using the other overload seems to leave the behaviour intact. Is it safe to switch to the simpler overload? When would I want to pass in the IWin32Window paramete...