Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set max length of datagridview column

I have a DataGridView where the units can be entered in a TextBox column.

How do I restrict the input length of this column to 6 characters?

like image 857
Jim Lahman Avatar asked Oct 15 '12 19:10

Jim Lahman


1 Answers

Use the MaxInputLength property of the DataGridViewTextBoxColumn.

This property is available through the Designer or through code:

((DataGridViewTextBoxColumn)dataGridView1.Columns[yourColumn]).MaxInputLength = 6;
like image 178
Jay Riggs Avatar answered Sep 17 '22 21:09

Jay Riggs