winforms

datagridview apply cellstyle to cells

I used this example to create a DateTime column for a DataGridView in my winforms app. http://msdn.microsoft.com/en-us/library/7tas5c80.aspx I can see the new column in the Windows Forms Designer and add it to an existing DataGridView. However, I want to be able to change the display format when I change the "DefaultCellStyle" within t...

Close PrintPreviewDialog when ESC is pressed

I'm working on a WinForms application that uses System.Windows.Forms.PrintPreviewDialog to display a Print Preview dialog. When the user presses ESC in that dialog, I'd like to close the dialog. Unfortunately, I can't figure out how to do this. I've tried to install a KeyDown/PreviewKeyDown event handler, but it never gets called. I ...

Hide / Show Winforms GUI C# from another thread.

This post is continuation of http://stackoverflow.com/questions/2167625/way-to-quickly-show-hide-winforms-gui-c, as it doesn't work for me in this particular case. I've got 2 problems: 1 is that the mainAnnounceWindow gui should start hidden and later on when called by: windowStateChange("Show") it should show, by windowStateChange(...

ASP.NET GridView Row Methods Counterparts in WinForms DataGridView

Are there any ASP.NET GridView's RowCreated, RowDataBound counterpart methods? All I want is to break a string into lines before displaying. I've put Environment.NewLine to create a line break but have no success till now. So I think I need to RowCreated or RowDataBound, etc. events to make modifications. ...

activex in winform

I need to put some activeX in my .Net WinForm. The provider had sent me a .tlb and the com .dll. Is this enough? How do I put it on winform? ...

Elegant Log Window in WinForms C#

I am looking for ideas on an efficient way to implement a log window for a windows forms application. In the past I have implemented several using TextBox and RichTextBox but I am still not totally satisfied with the functionality. This log is intended to provide the user with a recent history of various events, primarily used in data-g...

Convert Form to UserControl

I have a 3rd party code library that I'm using; part of this library is a winforms application for editing the configuration files used by this library. I would like to embed their configuration editor app into my application. I have the source code to their library and the configuration editor is (as far as I can tell) a straight forwa...

How to allow only character valid in a Windows file system in a TextBox that can only appear as uppercase in Winforms?

Is there an easy way for this? About the set of characters allowed in a Windows file system (Char.IsLetterOrDigit is not enough) How do I make the characters that are typed as uppercase? ...

Scrolling ListView with mouse wheel occasionally negates scroll

I'm having some trouble with the Win32 listview, and I hope someone has some wisdom. When scrolling very quickly (via the wheel), occasionally, the listview appears to scroll, only to jump back to the selected item so it is in-view. In other words, the list undoes your wheel scroll to show you the selected item at the top/bottom of the l...

How to disable horizontal scrollbar for table panel in winforms

Hi I've a tablelayoutpanel and I'm binding controls to it dynamically. When the item count exceeds the height of panel obviously vertical scroll bar appearing there is no problem. But the same time horizontal scroll bar is also appearing even the items width is less than the width of panel. How can i prevent this? ...

Refreshing Telerik's Rad DataGridView data on every x seconds

Hey guys, I am using Telerik RadGridView control in my C# WinForms app. I have user details showing up in the grid. I am trying to refresh data in my grid every x seconds. But no luck so far :( Your help would prove a great favor to me :) Here is what I have in my code-behind: public Dashboard() { InitializeComponent(); thi...

Form scaling issue on Chinese OS (96 dpi)

Hi All, I have a sample .net application which consist of 2 forms. I have used images and various controls over these forms. When I run this application under XP or Win 7 English version, it works fine. But, when I run this application under Chinese version OS, the form size changes. It increases the form size, causing distorted forms. ...

Opening a winform from a user control and passing back values to the usercontrol

Hi all I was wondering if it is possible to have a user control open a winform that allows a user to select options on it and then when he closes the form - the options / values he selected are returned to the user control? ...

Test Windows Forms logic with NUnit

Hello, I'm diving into unit testing and I would like to know if it is possible to test some special functionality of a dialog or a form with NUnit. I have tried NUnitForms, but it lacks good documentation and seems that nobody is mantaining that project. Is it true? If you have any experience testing Windows Forms, please point me in ...

C# Treeview doesn't refresh after moving nodes

In my windows application I have a treeview. I made custum buttons to move a node downwards. This is what happens when a button is clicked: Node destNode = tvCategories.SelectedNode.NextNode; Node srcNode = tvCategories.SelectedNode; Node parentNode = srcNode.Parent; // Switch nodes parentNode.Nodes[destNode.Index] = srcNode; parentNod...

Reassign textbox.text on bindingsource currentitem change event

I am just learning bindingsources etc. I have added my textbox databindings like so: txtTitle.DataBindings.Add("Text", bindingNavigator1.BindingSource.Current, "Title"); When the user clicks the next button on the navigator do I have to handle the bindingsource currentitem changed event to say txtTitle.Text = ((MyObject)bindingsourc...

Winforms Designer support to select Types and Controls

I have a Subclass of a BindingSource that just extends it a bit for our special needs, and I would like to support it for the VS2008 Designer. I have three properties, that I would like to get designer support for, two of them should be set to other Controls on the form, one should be set to a Type. Displaying them in den Designer as w...

ControlPaint.DrawBorder().....but thicker!?!?

I have the below code, which works, to draw a border around a control in a WinForm 3.5 app. What I can't figure out is how to THICKEN the border that is being drawn. I tried Inflate(5,5) on the ClientRectangle but that actually made the Border disappear all together versus making it thicker. I get the impression that I actually need...

Show all pages of PrintDocument on PrintPreviewControl

I'm having trouble creating multiple pages in a PrintDocument and displaying them within a PrintPreviewControl. I can create a single page easily enough, but stringing together multiple pages is eluding me. I'm going to eventually draw several pages of stuff using GDI, but I can't get something like this to work as expected. private P...

Clone Winform control

I have a groupox in a VB.NET winform app. The groupbox contains a few Labels, Textboxes and Checkboxes. This was created by simply dragging the controls out of VS toolbox. What I need to do is take the 1 Groupbox and at runtime create multiple Groupboxes to display based on user selection. Instead of dynamically creating the Groupboxes ...