Tag: C#
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 »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 »How to get value of advanced power settings
Some times you may need to get value of advanced power settings in your application. For example you may want to know after how much idle time, the system will hibernate of sleep. Here in this post I’ll…
Read More »Unit test a public method which relies on a protected method
Sometimes you need to write unit tests for a public method which is relying on some other protected methods. For example, lets say we have a business logic class which has a public GetGreatestId method, which returns the…
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 »How to get rid of BOM when downloading text from azure blob
When you download a text content using CloudBlockBlob.DownloadText() if the blob contains the BOM or byte order mark, then the returned text will contain some additional characters. For example in case of having UTF8 with BOM, you will…
Read More »