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

  • Thread starter Thread starter Pep
  • Start date Start date
P

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top