473,416 Members | 1,535 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,416 software developers and data experts.

How to limit the length of text entered into an item in a ListView?

Pep
Hi,

I'm using a ListView control in an app I'm developing...
When a user clicks the New button in my form I add a new ListViewItem
and call the BeginEdit() function on this item.

My problem is I wish to limit the text entered into the text for this
item to 70 characters. I notice that the data entered into the item
seems to be from a floating text box on top of the item. Is there any
way to get this textbox and set the MaxLength property?

I've also thought of using the AfterLabel edit event to verify this.
However this isn't ideal as I'd like the user to know as soon as they
hit 70 characters (ie they can't enter any more), rather than being
informed after the event. Also the
System.Windows.Forms.LabelEditEventArgs.Label property is read only and
I can't see any simple way of writing the newly shortened string to the
item...

Thanks in advance!

Pep

Nov 17 '05 #1
1 2546
Hi

You'll have to use these 2 command in the listview beforelabeledit

LVM_GetEditControl //gives u a handle of the edit box where the user
put in the new label in the list view

EM_LIMITTEXT //pass the maximum lenght required.

I have done it yet but I did in Delphi. At least you have a start point.

Ivan

Pep wrote:
Hi,

I'm using a ListView control in an app I'm developing...
When a user clicks the New button in my form I add a new ListViewItem
and call the BeginEdit() function on this item.

My problem is I wish to limit the text entered into the text for this
item to 70 characters. I notice that the data entered into the item
seems to be from a floating text box on top of the item. Is there any
way to get this textbox and set the MaxLength property?

I've also thought of using the AfterLabel edit event to verify this.
However this isn't ideal as I'd like the user to know as soon as they
hit 70 characters (ie they can't enter any more), rather than being
informed after the event. Also the
System.Windows.Forms.LabelEditEventArgs.Label property is read only and
I can't see any simple way of writing the newly shortened string to the
item...

Thanks in advance!

Pep

Nov 17 '05 #2

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

Similar topics

2
by: David | last post by:
Hello. In listview I have 3 collumns. How can I read text from 2rd ITEM - 2nd Subitem Example: Mark PEter June HEllo By All Sony Philips Panasonic This is listview:
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
12
by: MLH | last post by:
Can I somehow set a max length of chars entered into an unbound textbox control?
0
by: Dominique | last post by:
Hello, The aexview is showing four or five columns and most of the time only one or two is (are) useful in our environment Also the view is too big for our usual screens so I would like : - to...
4
by: pedalchick | last post by:
I'm trying to build a mini-CMS for a friend (ASP.NET 2.0/VB) - just a simple admin page w/ a text box and button that inserts some text into a database (I'm using Access 2003 - text is going into a...
4
by: Derty | last post by:
Any way to limit the length of databound text on a datalist itemtemplate?
1
by: | last post by:
Hello everyone, I am using a textbox for dumping information generated by the file system watch object. I am having this problem that always at some stage new new information stops being entered...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
6
by: iDesmet | last post by:
Good day! I was wondering if someone could show me the way with this little problem I have. I need to get the value/text of every checked SubItems in a listview so I can execute a Sub. The...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.