winforms

.NET: How to know when serialization is completed?

When I construct my control (which inherits DataGrid), I add specific rows and columns. This works great at design time. Unfortunately, at runtime I add my rows and columns in the same constructor, but then the DataGrid is serialized (after the constructor runs) adding more rows and columns. After serialization is complete, I need to cl...

Add close button (red x) to a .NET ToolTip

I'm looking for a way to add a close button to a .NET ToolTip object similar to the one the NotifyIcon has. I'm using the tooltip as a message balloon called programatically with the Show() method. That works fine but there is no onclick event or easy way to close the tooltip. You have to call the Hide() method somewhere else in your cod...

What's the best way to check for errors before leaving a row in a DataGridView

As far as I can tell, the best way to do this is do it in the DataTable.RowChanging event. But what if I want to cancel the action? There is no EventArgs.Cancel option... ...

Add DataSource Property to a Custom WinForms Control

Hi All, I want to add complex databinding to my custom winforms control. So I can do the following: myControl.DisplayMember = "Name"; myControl.ValueMember = "Name"; myControl.DataSource = new List<someObject>(); does anyone know what interfaces etc have to be implemented to achieve this? I've had a look into it and all I can find i...

Two-way data binding objects

I used an application recently that was awe-inspiring. All the forms inherited from their own classes and a 'form' came with an amazing amount of functionality and looked the nuts. What I'm interested in is this 'feature' of the form. This was a C# WinForms project and blew me away. The forms were bound to objects that the group had wr...

Access Edit Mode Values of BindingSource Control

I have a BindingSource control (http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.aspx) with a datasource of a (single) Linq object. If I change any of the properties of the underlying Linq-to-Sql object then all the other changes on the bound controls on the form are lost. Does anyone now why and how I work ar...

Is Visual Studio written in winforms?

Is Visual Studio written in .NET winforms? Or is winforms just too slow for a editor type application? ...

Handling a Click for all controls on a Form

I have a .NET UserControl (FFX 3.5). This control contains several child Controls - a Panel, a couple Labels, a couple TextBoxes, and yet another custom Control. I want to handle a right click anywhere on the base Control - so a right click on any child control (or child of a child in the case of the Panel). I'd like to do it so that ...

Winform create table in RichTextBox control

I need to create a simple editor using a RichTextBox control in a windows forms application that includes the ability to create tables. Is it possible to create a table in a RichTextBox control? If so, any pointers on the best way to do this would be appreciated. ...

Windows Forms - Multiple Event Loops

I have a Windows Forms (.NET) application that can have multiple documents open simultaneously. It would be convenient to have each document (form) running its own event loop. With brief experimentation, starting several event loops in their own STA threads seems to work. Is there any reason why this is a bad idea? ...

DataGridView sort and e.g. BindingList<T> in .NET

Hi Folks I'm using a BindingList<T> in my Windows Forms that contains a list of "IComparable<Contact>" Contact-objects. Now I'd like the user to be able to sort by any column displayed in the grid. There is a way described on MSDN online which shows how to implement a custom collection based on BindingList<T> which allows sorting. But ...

Is it possible to format Tooltip-Text (bold, underline... etc) ?

I want to make some passages of a standard tooltip bold in a WinForms application. Is this possible? If not, is there a (free) tooltip component that allows me to style them (preferably also border and background)? Thanks! ...

Databinding DropDown Control in .Net

I am binding the dropdown with db entity. ddlCustomer.DataSource = Customer.GetAll(); ddlCustomer.DataTextField = "CustomerName"; ddlCustomer.DataBind(); I want to add "SELECT" as the first itemlist in dropdown and bind then entity to the dropdown. How can i do this? ...

How do I add a console like element to a c# winforms program

I have a program that monitors debug messages and I have tried using a TextBox and appended the messages to it but it doesn't scale very well and slows way down when the number of messages gets large. I then tried a ListBox but the scrolling was snapping to the top when appending new messages. It also doesn't allow for cut and paste lik...

Locking down valid characters in a Textbox

I need to be able to lock down the valid characters in a textbox, I presently have a regex which I can check each character against such as [A-Za-z] would lock down to just Alpha characters. protected override void OnKeyPress(KeyPressEventArgs e) { if (e.KeyChar == (char)Keys.Back) { base.OnKeyPress(e); return; } ...

Why does the DoubleBuffered property default to false on a DataGridView and why is it protected?

We had a performance issue with DataGridViews where the redraw was horridly slow and found the solution Here to create a derived type and enable double buffering on the control. (Derived type is necessary since the DoubleBuffered property is protected) It doesn't seem like there's any drawback to having the DoubleBuffered property set t...

.NET Spell Check control?

Are there any libraries out there (preferably a self contained Text Edit Control) for .NET that have Spell Check capabilities. I would like to add the typical red underline to miss-spelled words in the edit area of my application. Edit: To clarify, this is for WinForms ...

Is it appropriate to use "Wingdings" fonts in a Windows Forms or WPF app?

I have a WPF control, that has a list of "Investors", and in the right column of the list, a "Delete" button. I could either waste some time making an image of an "x" in photoshop. Or, I could just use Wingdings font and set the content to "Õ" (which makes a cool looking delete button). Is this appropriate? My thinking is... while not ...

How do I create a subclass of TabPage that I can edit like a UserControl?

I want to create a subclass of TabPage that contains some control, and I want to control the layout and properties of those controls through the designer. However, if I open my subclass in the designer, I can't position them like I could on a UserControl. I don't want to have to create a TabPage with an UserControl instance on it, I wa...

simple DataGridView refresh question

whats the best way to refresh a DataGridView when you update the base data source? i'm updating the datasource frequently and wanted to display the outcome to the user as it happens. i've got something like this made (and it works), but null'ing out the DataGridView.DataSource doesnt seem like the right way. List<ItemState> itemStates...