Skip to main content

CODING

C# - DataGridView - Enable Typing In Combobox Cell

Default behavior of a DataGridViewComboBoxCell is that it doesn't support typing into the cell.

But you could have a request from the client who wants to have enabled typing in a Combobox cell. In order to achieve this, you need to perform two things:

- the DropDownStype property of the ComboBox editing control needs to be set to DropDown. This will enable typing in the combobox.

SilverStripe - How to Logout Inactive Users

SilverStripe content management system is near version 3, the latest stable version that will be released in several months, and we continue to provide SilverStripe tips and tricks to you.

This article shows how to logout inactive user after some period of time.

C# - DataGridView - How to Make Image Column Not Show Any Images

If a DataGridView control on your form contains an image column and cell and need to display null values, it will be replaced with the standard "X" image.

If you need different behavior, i.e. to make sure that no image will be displayed, you have to change the NullValue property of the column to "null".

Here is the code example demonstrates setting the NullValue for an image column:

this.dataGridViewImageColumn1.DefaultCellStyle.NullValue = null;

C# - DataGridView - Cell Text Wrap

By default, text in a DataGridViewTextBoxCell does not wrap. This can be controlled via the WrapMode property on the cell style (e.g. DataGridView.DefaultCellStyle.WrapMode).

Set the WrapMode property of a DataGridViewCellStyle to one of the DataGridViewTriState enumeration values. 

The following code example uses the DataGridView.DefaultCellStyle property to set the wrap mode for the entire control.

this.dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;

C# - DataGridView - Drag and Drop Rows Reorder

The DataGridView controls doesn't have enabled drag and drop reordering rows by default. However, here is the code that you use in the future in your projects in order to implement rows reordering with drag and drop.