winforms

How to use "this" properly to access the form controls?

Hello, In my case I have panels,but to make it clear I will use buttons in my example. I have 5(or more) buttons and I set an event,for example - OnMouseHover, to all of the five buttons.How do I get ,which one has the mouse hovered if all the events link to one method To capture the button where the mouse is hovered,I tried using "th...

Preventing a combo from dropping down

Is there an easy way of disabling the drop-down part of a combo box? I want to prevent the user from seeing the items in the drop-down part in some scenarios. EDIT Thanks to all who replied so quickly! I had already considered the option of placing a textbox or label in the same location as the combo box and then hiding the combo-box ...

How do I handle drag-and-drop in the designer?

I've created a control, DataGridViewContainer, that fakes partial-line scrolling in a DataGridView - basically it's a panel and a scrollbar and a few event handlers. I'd like to be able to use DataGridViewContainer at design time, dragging a DataGridView onto it to set its .DataGridView property to the dragged control. How do I handle ...

Capturing key presses for form but not for controls

I have a simple modal form which I'd like to close when Esc key pressed. It's simple doing this handling form_KeyDown event. The problem is the controls on the form. When the form first launched one of the buttons get focus and pressing Esc of course doesn't do anything. Disabling TabStop of every button prevents this but again Esc stops...

How to set the equivalent of Region on a ToolStripItem

Is there a way in Winforms to change the shape of a ToolStrip item. If it were a panel, I could set the Region to my GraphicPath object. But for ToolStripItem, I don't know how to do this, since it isn't derived from Control. ...

Redirect WinForms web browser Control pop ups to another WinForms web browser control with form data

I have a c# web browser and one of the pages it displays has a form. When the form is submitted it posts data to a new window in IE. I want to catch that data and forward it to another C# web browser that I have in my application. So I don't want it to open an IE browser when the javascript function window.open is called, I want it to ...

Can a bound DataGridView use text cell for boolean values?

I have a DGV bound to a list of objects. This works fine except that one of the object properties is boolean and therefore displays as a checkbox but I would prefer a simple yes/no text field instead. I've considered adding an additional column and populating with the appropriate string based on the boolean value but this seems a little ...

How to determine how long a song is using winmm.dll?

I've P/Invoked the mciSendString method from WinMM.dll: [DllImport("winmm.dll")] private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback); I can play, pause, and stop songs (I can also open/close the CD drive, but that's not im...

Help with adding checkbox column to DataGridView in window form

Hi I am trying to add a checkbox column to a DataGridView in a simple window forms application. I am pulling back some data from a database using ADO.NET, putting into a datatable, and then setting the datagridview datasource to the datatable. I then want to add a checkbox column as the second column. So far I have this code that seems...

Winforms data binding: need to know when my data gets saved

Hi, I can't believe I haven't run into this issue before: I have a data bound form and before the user navigates to another record I want to save some additional data from non-bound controls in addition to the bound data. The only event I can find is BindingManagerBase.PositionChanged but this seems to happen after the current record has...

Making a Webservice Method Asynchronous in C#/Winforms

Lets say I am calling some web service method that I do not control. This method takes a long time to run, and whoever developed the web service did not think to include a asynchronous version. What is the best way to create an asynchronous wrapper for such a method in C#/winforms? At the moment I am using a ThreadPool to run the webs...

Perform dragdrop implementation after DoDragDrop method is called

Hello I've been struggling with this for quite a while My application contains a list view, populated with file-names, which are located on a server. I'm trying to implement drag and drop functionality, so the user can drag files from my application into his/her's local computer. In order to do this, first i'm downloading the files i...

Filter input from keyboard in Textbox, C#

Hi, I want to filter the keyboard inputs into textbox based on the type of input I allow. e.g. 0 for Digits only 1 for Alphabets only 2 for Alphanumerics So if 0 is configured and a character 'a' is pressed on the keyboard, it is not shown in the textbox. How do I do that in C#? Thanks ...

C#: How to cleverly design a GUI for a Desktop Application with encapsulation in mind

Hey everyone! I am developing a desktop application with a MainForm that's grown rather large. There are lots controls in several containers on different levels (SplitContainers, TabPages, Panels). Now I want to refactor this class by separating all the controller code responsible for data binding & clearing the controls or carrying ou...

How to set column header text for spesific column in Datagridview C#

Hi, How to set column header text for specific column in Datagridview C# ...

c# sending mail from window form not triggering

Hello. I'm having some wierd behaviour in my WinForm application coded in c#. in my: private void buttonSave_Click(object sender, EventArgs e) Im calling my function: functions.sendStatusEmail(); The weird thing is that, when i press the Save button then email send is not triggered. But if I close my application the mail is handle an...

Form not repainting itself

How can I make the FileOpenDialog disappear? private void ofdAttachment_FileOk(object sender, CancelEventArgs e) { string fullFilename = ofdAttachment.FileName; string filename = Path.GetFileName(fullFilename); string dirName = Path.GetDirectoryName(fullFilename); this.Parent.Refresh(); this.Refresh();...

WinForms control for image map editing

In a WinForms application, I need to be able to interactively edit "hot" areas on top of an image, later to be used as a sort of image map. I tried to rig together an UserControl with some floating rectangles (Microsoft.VisualBasic.PowerPacks ftw) on top of a PictureBox, but the result wasn't all that pretty, especially with flickering...

How to build multilingual Crystal reports

We are developing a multilingual Winforms application using visual studio 2008. I am trying to figure out how I can create multilingual reports using crystal Reports. Is there any thing similar to .net resource files in the Crystal reports world? ...

c# Winforms Controls rendering the components they are positioned over to a bmp (intelligent screenshot?)

The problem: I have a UserControl (LightBox) which overlays a number of other controls to allow the user to see the controls it is positioned over, but not allow the users to interact with the controls under the Lightbox. Winforms is (almost notoriously as I'm finding out) bad at handling alpha-blending. Question: How can I get the Li...