ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2016-03-01 06:09:23

asparatu
Member
Registered: 2014-08-20
Posts: 196

Limit the Text Length

Hello Jing,
   Is there a MaxLenght method for the cells? or will i have inherit the reogridcell and add it myself? or i can do this.. can add to the celltextchanged event? if do that will impact performance?

Thank you,
shane

Offline

#2 2016-03-02 03:07:02

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: Limit the Text Length

Hi Shane, for different cases there could be several ways that cell text can be changed. Directly input is one of that, copying and pasting should also be checked, same to the dragging mouse to copy/move cells data.

If you just allow your users to simply edit on the worksheet, the following code that limits the max length to 5 chars may work for you.

Dim sheet = ReoGridControl1.CurrentWorksheet

AddHandler sheet.CellEditCharInputed, Sub(s, ea)
  If sheet.IsEditing Then
    If sheet.CellEditText.Length > 5 AndAlso ea.InputChar <> 8 Then
      ea.InputChar = 0
    End If
  End If
End Sub

Where ea.InputChar <> 8 is used to detect the Backspace input in order to deleting text, which will be performed by ReoGrid core so that we don't need to check it from future versions.

Last edited by Jingwood (2016-03-02 03:13:10)

Offline

#3 2016-03-02 07:53:59

asparatu
Member
Registered: 2014-08-20
Posts: 196

Re: Limit the Text Length

Hello Jing,
  Ok.. I will try this and get back to you, Thank you
Shane

Offline

Board footer

Powered by FluxBB