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 2014-08-27 06:27:56

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

Numeric Only

I would like to know how can if the someone paste text into the cell it will remove the text? I have the could to check the cell for numeric only but that is if the click on the cell and add it, but it does not work if they paste text into the cell..
Thank you
Shane

Offline

#2 2014-08-27 06:52:50

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

Re: Numeric Only

You could use the 'BeforePaste' event, see http://reogrid.net/document/clipboard/ and Demo program for 'Clipboard Events'.

Good luck!

Offline

#3 2014-08-28 02:47:19

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

Re: Numeric Only

here is the code i use to do what i wanted

thought i would share it someone else wanted to use it

this basically checks for numeric values if you paste into grid from the clip board.. and if alpha is found it sets the that value to nothing

 With grid
            Dim data(,) As Object
            Dim range As ReoGridRange


            data = RGUtility.ParseTabbedString(Clipboard.GetText)

            range = New ReoGridRange(.SelectionRange.Row, .SelectionRange.Col, data.GetLength(0), data.GetLength(1))

            For i As Integer = 0 To data.GetLength(0) - 1
                For j As Integer = 0 To data.GetLength(1) - 1
                    If Not IsNumeric(data(i, j)) Then
                        e.IsCancelled = True
                        data(i, j) = Nothing
                    End If
                Next
            Next

            .DoAction(New RGSetRangeDataAction(range, data)) 'So you can use undo and redo
        End With

Last edited by asparatu (2014-08-28 04:19:04)

Offline

#4 2014-09-05 02:37:38

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

Re: Numeric Only

Great! Thanks for sharing.

Offline

Board footer

Powered by FluxBB