Tag: Windows Forms
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 »DataGridView Password Column
Windows Forms have a few column types for DataGridView including DataGridViewTextBoxColumn, DataGridViewCheckBoxColumn, DataGridViewComboBoxColumn, DataGridViewImageColumn, DataGridViewButtonColumn and DataGridViewLinkColumn. You can also create custom columns for DataGridView by deriving from DataGridViewColumn or any of mentioned classes and provide a new…
Read More »Two-way data-binding to Dynamic Object
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 »