Hi,
Here is a class that inherits from a datagridtextboxcolumn that should
work.
Public Class MaxLengthColumn
Inherits DataGridTextBoxColumn
Private mintLen As Integer = 256
Public Property MaxLength() As Integer
Get
Return mintLen
End Get
Set(ByVal Value As Integer)
mintLen = Value
End Set
End Property
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal
instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText,
cellIsVisible)
MyBase.TextBox.MaxLength = mintLen
End Sub
End Class
Ken
-------------------
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:#t**************@TK2MSFTNGP12.phx.gbl:
I know how to set the max length for the datatable.
dtInvoice.columns.item("description").maxlength = 40
However, the effect as not good as textbox.
The user can input the 50 charactrers, as he/she press 'enter', there is a
messagebox prompt out.
I think it is not good for the user.. Any other idea ?
"Agnes" <HYPERLINK
"mailto:ag***@dynamictech.com.hk"ag***@dynamictech .com.hk> &b6l%s
news:%2****************@TK2MSFTNGP10.phx.gbl $$<6<g...
How Can I set the max length in the datagrid ?
Thanks
--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (
http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.6 - Release Date: 6/25/2004