pachecosita
asked on
Setting maximum Input lenght in Datagridview
How Do I set up maximum INPUT length programatically in datagridview (VB.NET)?
I am populating the Datagridview with a dataset
I am populating the Datagridview with a dataset
Use can use this code to set the max length
DataGridViewTextBoxEditingControl TextBoxControl;
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
TextBoxControl = e.Control as DataGridViewTextBoxEditingControl;
if (TextBoxControl != null)
{
TextBoxControl.KeyPress += TextBoxCellEditControlKeyPress2;
}
}
private void TextBoxCellEditControlKeyPress2(object sender, KeyPressEventArgs e)
{
TextBoxControl.MaxLength = 3;
}
You can set the MaxInputLength property of datagridview column like this.
((DataGridViewTextBoxColum n)this.dat aGridView1 .Columns[0 ]).MaxInpu tLength = 10;
((DataGridViewTextBoxColum
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://www.experts-exchange.com/questions/24445853/Max-Length-in-datagridview-column.html
jppinto