Show error icon when in edit mode

Posted by: imgodot on 8 September 2017, 3:25 pm EST

  • Posted 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    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



  • Marked as Answer

    Replied 8 September 2017, 3:25 pm EST

    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

  • Replied 8 September 2017, 3:25 pm EST

    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

  • Replied 8 September 2017, 3:25 pm EST

    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
  • Replied 8 September 2017, 3:25 pm EST

    Hi Paul,

    You can probably upload it to google drive and provide me the link to download same.

    Thanks,
    Deepak Sharma
  • Replied 8 September 2017, 3:25 pm EST

    I have no doubt it's working on your side.
    I just don't understand why it isn't on my side.
    I've downloaded the sample several times with the same result.

    The last thing I would like to try is to send the test project back to you after I have downloaded it and run it on my side; where it fails.

    If you can run the exact same code that failed for me then I'll have to deal with that.
    Unfortunately, the ZIPX of the project is 6.7 MB and the forum upload only allows 3 MB.
    How can I get the project to you?

    Thanks.
    -- Paul

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels