winforms

Is there a way to delay an event handler (say for 1 sec) in Windows Forms

I need to be able to delay the event handlers for some controls (like a button) to be fired for example after 1 sec of the actual event (click event for example) .. is this possible by the .net framework ? I use a timer and call my code from the timer's tick event as below but I am not sure if this is the best approach ! void onButtonC...

When do a DataGridView's cells' bounds and visibility change? What about rows?

I'm writing a cell and row class that will allow users to host controls inside DataGridViewCells and DataGridViewRows. I'm doing it by adding the control to the DataGridView's control collection and showing or hiding it at the appropriate position onscreen to overlay the cell or row. I need to find out when the cell or row's bounds or ...

How do I move a tooltip?

I'm using the CellToolTipTextNeeded event of a DataGridView, and the tooltip is being shown under the mouse. I can get the ToolTip object out via reflection, but I don't have any control over where it's positioned since I'm not the one calling Show(). How do I move a tooltip? ...

ItemDataBound for a Windows Forms DataGridView?

I am binding an array to a DataGridView. I have a column containing file paths which maps to a column of push buttons. I would like to pre-process the file path so that the DataGridViewButtonColumn displays only the file name (sans the parent folders). How do I intercept and pre-process values before they are bound to the columns of a D...

Using C# WinForms Designer on Panel instead of Form?

Warning: I'm new to GUI building in C# (come from a long history in Java with Swing and SWT.) Using VS2008, When I create a new class, and extend System.Windows.Forms.Form, the WinForms Designer works really nicely. However; when I create a new class and extend System.Windows.Forms.Panel, the designer does not work nearly as elegantly ...

What can cause a form to lose its link to its parent form in an MDI vb.net project?

Very periodically, some of our forms in our MDI vb.net project will return me.parent as nothing. I've never seen this while debugging, but it does cause an un-handled exception on our client machines - and the form that they have open varies from case to case. Is there any sort of event, short of a 'me.parent = nothing', that can cause...

OnMouseEnter for all controls on a form

I have OnMouseEnter and OnMouseLeave event handlers setup for my form. When the mouse moves over the form I want to set the opacity to 100% and when it moves away I want to set it to 25%. It works well, except when the mouse moves over one of the buttons on the form. The OnMouseLeave event fires and hides the form again. Is there a good ...

Trackbar Background in a TabControl

I have a TrackBar control on a TabPage inside a TabControl. The background of the TrackBar is being drawn in grey while the TabPage is being drawn as white. There is no way to set the BackColor property of the TrackBar to transparent, and I can't override the drawing because there is no DrawMode property for the TrackBar. What options do...

In C#, is there a way to consistently be able to get the selected text contents of currently focused window?

In my c# .Net application, I've been trying to be able to retrieve the currently selected text in the currently focused window. (Note that it can be any window open in windows, such as word, or safari). I'm able to retrieve the handle to the currently focused control. (Using a couple of interop calls to user32.dll, and kernel32.dll). ...

Get available controls from form using c#

How to get Available controls from winForms using c# ...

Problem with NotifyIcon: "Hide Inactive Icons" not working

Hi! I am using C# (.NET 3.5) and use the NotifyIcon to enable "Minimize to Systray". Everything is working great, except that the shell registers the systray icon with the title "No title" when you look at the start menu properties -> "Hide Inactive Icons". Also changing the setting for that systray icon to "Always Show" or "Always Hid...

Key Events

Is there a way to handle the multiple key-press event on a C# windows form, like "Ctrl+E" ? Here's my code: private void frmDataEntry_KeyDown(object sender, KeyEventArgs e) { if (Control.ModifierKeys == Keys.Control && e.KeyCode == Keys.E) { //Code } } This condition is always false .. why? I ...

Will WPF replace WinForms?

Is WPF expected to replace WinForms in the near future, or is it more of a complimentary technology, intended for applications that have a strong graphical content? Answers that link to statements from Microsoft will be most appreciated! (I looked already, but could not find anything definitive) ...

How to reduce memory consumption by an application in Task manager

Hi I have developed a winforms application using C# in VS2008. When I run this application I observed in task manager that it shows 80 MB of memory is consumed. How can I reduce this? Even very small applications also take 8 MB of memory... What can I do to reduce the memory footprint? Thank you very much in advance. ...

How do I find out whether a control is currently invalidating?

I'm writing a custom DataGridView cell class that hosts a control. I'm listening to the Invalidated event to know whether I should reposition and repaint the cell, but I'm getting loops because repositioning the cell can invalidate other hosted cells, which then invalidate the first one, and so on. I don't want to use a static member t...

Can I have an 'offscreen' control?

I'm trying to create a DataGridView cell class which hosts a control (all the time, not just while editing). So far, my approach has been to add the control to the grid and try to synchronise its position with that of the cell. Would it be possible instead to keep the cell offscreen, route mouse and keyboard events to it, and paint it ...

Implementing MVC with Windows Forms

Where can I find a good example on how to completely implement the MVC pattern in Windows Forms. I found many tutorials and code examples on various sites (e.g. CodeProject, .NetHeaven) but many are more representative for the observer pattern than MVC. Since the application I want to develop is for a school project, I am reluctant to us...

WPF WinForms Interop issue with Enable / Disable

I have a WinForms usercontrol hosting a WPF custom Listbox in it. After the WinForms user control gets disabled and then re-enabled the WPF control in the WinForms usercontrol is unresponsive. Has anyone else experienced this? We had to hack a soultion into remove and re-add the element host each time the control gets disable / enable...

How to detect if items are added to a ListBox (or CheckedListBox) control

This seems like a fundamentally simple question. I have a WinForms dialog box with a listbox. This control is not populated via data-binding but is filled with calls to listBox.Items.Add (obj); It is possible that this call can be made asynchronously from various places and I would like to hook the listbox and watch for changes in it...

Viewing all event handlers associated with a Button?

I have a number of Inherited User Controls, for each User Control I sometimes have overridden event Handlers for the Buttons on the Control. (To allow for Child specific behaviours to occur) Is there a way of viewing all the Event Handlers associated with a particular component? The problem being that on one of the Buttons, the event h...