473,388 Members | 1,198 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to limit the TextLenght in a column in a DataGrid?

Hi,

I have a Datagrid, and I want to limit the Lenght of the text in a certain
column to a certain number of characters (for exemple 10).

What I want is that, when the user is typing in the column, that he can't
type more than the 10 characters (not that they are concattenated during
input or something like that).

Anybody any idea?

Thansk a lot in advance,

Pieter
Jul 21 '05 #1
7 1774
You have to limit it on the Column object off the Table that is attached to
the datagrid.

Table.Columns(0).MaxLength = 10

I'm not positive that will limit the entry side of things, but I believe
that it does.

Chris
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a Datagrid, and I want to limit the Lenght of the text in a certain
column to a certain number of characters (for exemple 10).

What I want is that, when the user is typing in the column, that he can't
type more than the 10 characters (not that they are concattenated during
input or something like that).

Anybody any idea?

Thansk a lot in advance,

Pieter

Jul 21 '05 #2
It works, but not at keypress time.

I think you might have to create your own class and overide the keypress event if you want
to achieve
the effect of discarding the keystroke when the limit is reached.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com> wrote in message
news:O$**************@TK2MSFTNGP11.phx.gbl...
You have to limit it on the Column object off the Table that is attached to
the datagrid.

Table.Columns(0).MaxLength = 10

I'm not positive that will limit the entry side of things, but I believe
that it does.

Chris
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a Datagrid, and I want to limit the Lenght of the text in a certain
column to a certain number of characters (for exemple 10).

What I want is that, when the user is typing in the column, that he can't
type more than the 10 characters (not that they are concattenated during
input or something like that).

Anybody any idea?

Thansk a lot in advance,

Pieter


Jul 21 '05 #3
Yep, that's what you will have to do then. Unless someone smarter than me
know something I don't.

Chris
"Mark Jones" <no**************@devnullbucket.org> wrote in message
news:41***********************@news.twtelecom.net. ..
It works, but not at keypress time.

I think you might have to create your own class and overide the keypress
event if you want
to achieve
the effect of discarding the keystroke when the limit is reached.
"Chris, Master of all Things Insignificant" <chris@No_Spam_Please.com>
wrote in message
news:O$**************@TK2MSFTNGP11.phx.gbl...
You have to limit it on the Column object off the Table that is attached
to
the datagrid.

Table.Columns(0).MaxLength = 10

I'm not positive that will limit the entry side of things, but I believe
that it does.

Chris
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I have a Datagrid, and I want to limit the Lenght of the text in a
> certain
> column to a certain number of characters (for exemple 10).
>
> What I want is that, when the user is typing in the column, that he
> can't
> type more than the 10 characters (not that they are concattenated
> during
> input or something like that).
>
> Anybody any idea?
>
> Thansk a lot in advance,
>
> Pieter
>
>



Jul 21 '05 #4
set DataGridTextBoxColumn.TextBox.MaxLength to 10 in code. I think you know
where to use DataGridTextBoxColumn.
Jul 21 '05 #5
ok thanks!

"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
set DataGridTextBoxColumn.TextBox.MaxLength to 10 in code. I think you know where to use DataGridTextBoxColumn.

Jul 21 '05 #6
how do you use datagridtextboxcolumn?

"Rulin Hong" wrote:
set DataGridTextBoxColumn.TextBox.MaxLength to 10 in code. I think you know
where to use DataGridTextBoxColumn.

Jul 21 '05 #7
Dim tbc As DataGridTextBoxColumn = CType(tbsTabelStyle.GridColumnStyles(3),
DataGridTextBoxColumn)

AddHandler tbc.TextBox.MouseMove, AddressOf TextBox_MouseMove

AddHandler tbc.TextBox.TextChanged, AddressOf TextBox_TextChanged
"David Baumgarten" <Da*************@discussions.microsoft.com> wrote in
message news:A5**********************************@microsof t.com...
how do you use datagridtextboxcolumn?

"Rulin Hong" wrote:
set DataGridTextBoxColumn.TextBox.MaxLength to 10 in code. I think you know where to use DataGridTextBoxColumn.

Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Urban | last post by:
hi, I have a question. Maybe You know the equivalent to command LIMIT from MySQL I couldn`t find something like this in MS SQL PS I try to display 10 records begining form e.g. 4 sort by id...
3
by: Rakesh | last post by:
Hi, Is there any limit to the number of rows a datagrid can display? Thanks, Rakesh
1
by: Jax | last post by:
Only way I can figure it at present is to do some string manipulation so I can catch the '.' and count the chars and cut after a certain point Does anyone know an easier way to do this? The data is...
3
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is...
6
by: Aaron Smith | last post by:
Is there a way to put a limit on the text size of a datagrid column? Thanks, Aaron -- --- Aaron Smith Remove -1- to E-Mail me. Spam Sucks.
7
by: DraguVaso | last post by:
Hi, I have a Datagrid, and I want to limit the Lenght of the text in a certain column to a certain number of characters (for exemple 10). What I want is that, when the user is typing in the...
4
by: Melson | last post by:
Hi I've a problem. Can anyone help. I would like to use datagrid for data entry. How can I set the number of rows in the datagrid. And use the datagrid to update the ms sql table. regards...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.