Show error icon when in edit mode

  • imgodot 1 month, 3 weeks ago

    What would the code for a custom cell-type be in order to display the error icon when the cell is in edit mode?

    Thanks.
    – Paul

  • 15p
    Kevin Ashley15p 1 month, 3 weeks ago

    Hi Paul,

    I will need to ask the developers about this one, but I assume that you are looking for something like an icon that shows up in the cell during edit mode when certain conditions are meant? Please correct me if I am misunderstanding the functionality you are looking for.

    Regards,
    Kevin

  • imgodot 1 month, 3 weeks ago

    Kevin,

    STANDARD BEHAVIOR:
    The error icon will show up in a grid cell when the ErrorText string property is not empty and ShowCellErrors = TRUE.
    When a cell displaying the error icon enters edit mode, the error icon disappears.

    I am looking for a way to have the error icon display when the cell is in edit mode or not.
    Side note, I use the TextIndent property now to prevent the cell contents from overlapping the error icon in the cell.

    Thanks.
    – Paul

  • 15p
    Kevin Ashley15p 1 month, 3 weeks ago

    Hi Paul,

    Do you already have some code for this? I can take a look at what you have so far and change it so that it works to show the behavior you are looking for.

    Regards,
    Kevin

  • imgodot 1 month, 3 weeks ago

    Kevin,

    I really have no code for this AT ALL.
    I have no clue what is required or where to begin.
    If you want to use my custom date edit cell-type as a starting place, the code is below.

    Thanks.
    – Paul

    Public Class MCS_DateTimeCellType_ORIG
        Inherits FarPoint.Win.Spread.CellType.DateTimeCellType
    
        Private WithEvents Editor As New FarPoint.Win.Spread.CellType.GeneralEditor
    
         '==========================================================================================================
        ' If the editor "Value" is not a date then assign it a value of 1/1/1900. 
        ' This prevents an invalid data error when the user blanks a date cell and tabs off.
        '==========================================================================================================
        Private Sub Editor_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Editor.Validating
            If IsDate(Editor.Value) = False Then
                Editor.Value = #1/1/1900#
            End If
        End Sub
    
        ' Format the datasource value to display in the grid.
        Public Overrides Function Format(ByVal obj As Object) As String
            If IsDate(obj) = False Then
                Return ""
            End If
    
            If DateValue(obj.ToString) = #1/1/1900# Then
                Return ""
            Else
                Return DateValue(obj.ToString).ToString("MM/dd/yyyy")
            End If
    
        End Function
    
        ' Format the grid value to send to the datasource.
        Public Overrides Function Parse(ByVal s As String) As Object
            If s Is Nothing OrElse String.IsNullOrEmpty(s) Then
                Return #1/1/1900#
            Else
                If IsDate(s) = False Then
                    Return #1/1/1900#
                Else
                    Return DateValue(s)
                End If
            End If
        End Function
    
    End Class
  • 15p
    Kevin Ashley15p 1 month, 2 weeks ago

    Hi Paul,

    I thought at first that this might be better with conditional formatting and an icon rule, but it doesn’t show the icon when the cell is in edit mode, only when it is not in edit mode. I think this might require a custom celltype, but I have asked the developers for confirmation and I will get back to you on that. The tracking number for this is 236633. I will let you know as soon as I have an answer.

    Regards,
    Kevin

  • 15p
    Kevin Ashley15p 1 month ago

    Hi Paul,

    I sincerely apologize for the delay. It looks like the case was assigned to the wrong person, so I never saw the update. Here is a project that the developers put together that shows the behavior you are looking for:

    http://cdn.grapecity.com/support/spread/Kevin%20Ashley/Customer%20Tickets/236633%20CustomErrorIcon.zip

    Let me know if that helps.

    Regards,
    Kevin

  • imgodot 1 month ago

    Kevin,

    I downloaded the sample and ran it.
    Unfortunately, it doesn’t work properly.

    If the cell displays an error icon, it cannot be edited.
    Which is totally useless because you can’t edit the cell to fix the error condition.

    – Paul

  • 15p
    Kevin Ashley15p 1 month ago

    Hi Paul,

    I looked into that sample, and it looks like there is a description at the top that says what the cell type does:

    // Show error icon when:
    // – ErrorText string property not empty
    // – ShowCellErrors = True
    // – Both in and out of edit mode
    // – Use TextIndent property to prevent the cell contents from overlapping the error icon

    You could change the code in that sample to fit your needs (i.e. change it so that it checks the value of the cell and not the ErrorText string), but that code should be enough to implement this functionality.

    Regards,
    Kevin

  • imgodot 1 month ago

    Kevin,

    Huh?

    The dev’s statement of what the cell-type does is NOT what it does.
    What is the point of their code, if I have to modify it to even do what they say it does?

    – Paul

  • 15p
    Kevin Ashley15p 1 month ago

    Hi Paul,

    With the project I sent I saw that the error icon did show both in and out of edit mode. The problem is there doesn’t appear to be any conditions set up for when that icon shows. For example, say you want to show the icon only when the number is below 2. In the project, that icon shows no matter what, so I have asked the developers how exactly it can be changed to implement some conditions for when the icon should be shown. I did see that I could edit the cell no matter what, so I’m not sure how you are unable to edit the cells with that project. I will get back to you when I have more clarification from the developers to ensure that something isn’t wrong in the project.

    Regards,
    Kevin

  • imgodot 1 month ago

    The only difference on my side is that I replaced the references to Spread 8.35 with references to version 10.40.20171.0.
    Other than that, I made no changes.
    There are no errors or warnings.
    I have cleaned and rebuilt the project.

    I can edit the other columns and I can edit the cell in the “Text” column that has no error icon.
    But, when I double-click in a cell with an error icon, I see the cell flash and it shows an insertion point for a moment, then it loses edit mode.

    If a cell with an error icon has focus and I press keys I can see the insertion point flash in the cell editor but the contents don’t change. Nothing I do affects the value in the cell.

    Can you please try the project using Spread 10?

    Thanks.
    – Paul

  • 50p
    Deepak Sharma50p 4 weeks, 1 day ago

    Hi Paul,

    I am having no trouble editing the custom cell with error icon using Spread for Windows Forms v8.35.20143.0. Please refer to the attached image.

    Regards,
    Deepak Sharma

    Attachments:
    You must be logged in to view attched files.
  • imgodot 4 weeks, 1 day ago

    I understand that it works with Spread 8.35.
    I don’t understand why it doesn’t work for me.
    The only change I made to the project was to replace the Spread 8.35 references for Spread 10.

    Can you please verify that it runs correctly with Spread 10 on your side?

    – Paul

  • 50p
    Deepak Sharma50p 3 weeks, 4 days ago

    Hi Paul,

    This is working fine with v10 of Spread Studio as well. I am using Windows 10 64 bit and VS2017.
    Please refer to the attached image.

    Thanks,
    Deepak Sharma

    Attachments:
    You must be logged in to view attched files.
Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to create new topics.