473,320 Members | 1,933 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,320 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
Nov 21 '05 #1
7 4822
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

Nov 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


Nov 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
>
>



Nov 21 '05 #4
set DataGridTextBoxColumn.TextBox.MaxLength to 10 in code. I think you know
where to use DataGridTextBoxColumn.
Nov 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.

Nov 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.

Nov 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.

Nov 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...
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...
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: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order...
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.
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.