Home » Windows Forms

Print RDLC Report without Preview

Sometimes you have a report which you want to print without showing a preview in ReportViewer. You can print an RDLC report programmatically using LocalReport object and CreateStreamCallback callback function. There is an article in MSDN which describes…

Read More »

How to edit a List<string> in PropertyGrid

When you define a property of List<string> type for a control, if you try to edit the property in PropertyGrid, a collection editor form will open and if you click on add button on the editor form, you…

Read More »

How to add item to Windows shell context menu to open your application

Sometimes when installing applications, you want to add an entry to the windows shell context menu to open your application and pass the selected file or folder name to your application. In this post I’ll show how to…

Read More »

Enable designer of child Panel in a UserControl

Sometimes you want to create a composite user control and allow users to interact with the user control at designer when they drop an instance of your user control on a form. For example, let’s say we are…

Read More »

DataAnnotations Validation Attributes in Windows Forms

In this post, I’ll show how to use Data Annotation Validation attributes to perform validation in a Windows Forms Application. Data Annotation Validation attributes enable you to perform model validation simply by decorating class properties with validation attributes…

Read More »

Two-way data-binding to Dynamic Object

Dynamic Object Two Way Data Binding

To create a Dynamic Object which you can use for two-way data-binding to Windows Forms control, you should derive from DynamicObject and also implement ICustomTypeDescriptor and INotifyPropertyChanged interface. DynamicObject: Deriving from DynamicObject provides a solution for specifying dynamic…

Read More »

Auto-hide menu in Windows Forms

Some times you need to make the menu of the form auto hide to provide more space for other controls on the form. To show and hide the menu, it’s enough to set its Visible property. But to…

Read More »

Prevent raising of Validating event of focused control when Closing the form

When you have an event handler for Validating event of a control, if the value of AutoValidate property of the form is set to anything different from Disabled, then Validating event will fire when you try to close…

Read More »

Make a Property Read-Only in PropertyGrid

Sometimes you want to make a property read-only in PropertyGrid based on some criteria at run-time. For example, let’s suppose you have a SampleClass containing two properties, Editable and StringProperty and you want to make StringProperty read-only if…

Read More »