Home All Groups Group Topic Archive Search About

datagrid.textbox -maxlength problem

Author
3 Jun 2009 10:15 AM
Sze
I had set the maxlenght to 20, it is valid for me to input 20 chars
However, it also allow me to input 20 chinese words .
In fact, I only want to store 10 chinese words  & 20 english chars.

How can I do that ??
Thanks

Author
4 Jun 2009 7:05 AM
Cor Ligthert[MVP]
Sze,

I think that in this newsgroup very few people are active who really deeply
know Mandarin (I thought to know one who know something about it) therefore
you can better ask it in a Chinese newsgroup because there are people
knowing Mandarin (and other Chinese languages).

Cor

Show quoteHide quote
"Sze" <a**@abc.com> wrote in message
news:eQGJ9QD5JHA.5728@TK2MSFTNGP03.phx.gbl...
>I had set the maxlenght to 20, it is valid for me to input 20 chars
> However, it also allow me to input 20 chinese words .
> In fact, I only want to store 10 chinese words  & 20 english chars.
>
> How can I do that ??
> Thanks
>
>
Author
5 Jun 2009 4:51 AM
Sze
Thanks, could you tell me what is that news group name ?
I had search chinese but find nothing.



"Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
???????:OCpxlLO5JHA.3***@TK2MSFTNGP06.phx.gbl...
Show quoteHide quote
> Sze,
>
> I think that in this newsgroup very few people are active who really
> deeply know Mandarin (I thought to know one who know something about it)
> therefore you can better ask it in a Chinese newsgroup because there are
> people knowing Mandarin (and other Chinese languages).
>
> Cor
>
> "Sze" <a**@abc.com> wrote in message
> news:eQGJ9QD5JHA.5728@TK2MSFTNGP03.phx.gbl...
>>I had set the maxlenght to 20, it is valid for me to input 20 chars
>> However, it also allow me to input 20 chinese words .
>> In fact, I only want to store 10 chinese words  & 20 english chars.
>>
>> How can I do that ??
>> Thanks
>>
>>
>
Author
5 Jun 2009 8:38 AM
Andrew Morton
Sze wrote:
> I had set the maxlenght to 20, it is valid for me to input 20 chars
> However, it also allow me to input 20 chinese words .
> In fact, I only want to store 10 chinese words  & 20 english chars.
>
> How can I do that ??

Assuming a DataGrid behaves the same as a DataGridView, then you can attach
a handler to the editing control:

Private Sub myDGV_EditingControlShowing(ByVal sender As Object, ByVal e As
DataGridViewEditingControlShowingEventArgs) Handles
myDGV.EditingControlShowing
    RemoveHandler e.Control.KeyDown, AddressOf cellEditingKeyHandler
    AddHandler e.Control.KeyDown, AddressOf cellEditingKeyHandler
End Sub

Friend Sub cellEditingKeyHandler(ByVal sender As Object, ByVal e As
KeyEventArgs)
    ' Your code to detect the length of the cell content
End Sub

Where "Your code to detect the length of the cell content" determines how
many characters have been entered in the Sender. Presumably you know some
way of distinguishing between Chinese and English graphemes; perhaps if
AscW(someChar)>255 you can assume it's Chinese.

Andrew