Problem with custom celltype when migrating from Spread 1 to Spread 4

Posted by: harriscohen1 on 8 September 2017, 1:43 pm EST

  • Posted 8 September 2017, 1:43 pm EST

    Dear support,

    I have been using a custom celltype class in Spread 1 that draws a multicolumn combobox subeditor when my users type. However, when I upgraded from Spread 1 to Spread 4 I am now getting the following error:

    Run-time exception thrown: System.Resources.MissingManifestResourceException - Could not find any resources appropriate for the specified culture or the neutral culture.

    Below is the part of the code which is raising the error. The error is specifically triggered at rm.GetObject("dropDown").

     
        Public Overrides Sub PaintCell(ByVal g As Graphics, ByVal r As Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)

                Try

                    Dim newR As New Rectangle(r.X, r.Y, r.Width - SystemInformation.VerticalScrollBarWidth, r.Height)
                    Dim rm As New System.Resources.ResourceManager(GetType(FarPoint.Win.IElement))
                    Dim b As New FarPoint.Win.ButtonElement
                    b.Border = New FarPoint.Win.BevelBorder(FarPoint.Win.BevelBorderType.Raised, SystemColors.ControlLightLight, SystemColors.ControlDark, 1)
                    b.ForegroundImage = New FarPoint.Win.Picture(CType(rm.GetObject("dropDown"), System.Drawing.Image), FarPoint.Win.RenderStyle.StretchAndScale, Color.Magenta, FarPoint.Win.HorizontalAlignment.Center, FarPoint.Win.VerticalAlignment.Center)
                    Dim buttonRect As New Rectangle(r.X + r.Width - SystemInformation.VerticalScrollBarWidth, r.Y, SystemInformation.VerticalScrollBarWidth, r.Height)

                    MyBase.PaintCell(g, newR, appearance, value, isSelected, isLocked, zoomFactor)
                    b.OnPaintBackground(g, buttonRect)
                    b.OnPaint(g, buttonRect)

                Catch ex As Exception
                    MsgBox(ex.ToString)

                End Try

     

    Any ideas? 

  • Replied 8 September 2017, 1:43 pm EST

    Hello,


    Due to a performance issuem, we do not store this image in a resource and draw a picture on the button in the Spread code anymore. We now use the ControlPaint.DrawComboButton function to draw a button with the dropdown.

  • Replied 8 September 2017, 1:43 pm EST

    Hi Scott,

    I replaced the troubled code with ControlPaint.DrawComboButton(g, newRect, ButtonState.Normal). While the System.Resources.MissingManifestResourceException errors have been resolved. Two other issues have popped up.

    First, prior to entering the editmode, the cells with the custom celltype used to appear as a dropdown with the familiar arrow, now it just has a blank button and I can;t seem to get the cell appear like a combobox anymore.

    Second, previously when my users typed into the cell with custom celltype, a multicolumn subeditor would appear and as they typed the contents of the subeditor would be filtered but the focus remained on the custom cell. Now, after the users types a single character, the focus goes to the subeditor and I can't seem to figure out how to resolve this either?

  • Replied 8 September 2017, 1:43 pm EST

    Thank you. Would it be possible to post any code on how to do this?
  • Replied 8 September 2017, 1:43 pm EST

    Hello,

    As you suggested, I've been trying to capture the keystrokes in the SubEditor. I am using the MultiColumnList.KeyUp event but it is very unpredictable as the SubEditor comes and goes as I type. Is there a better way to capture the keystrokes when the focus passes from the Editor to the SubEditor?

    For what its worth, the upgrade to Spread 4 has been a painful one.

     
    Thank you.
     

     

  • Replied 8 September 2017, 1:43 pm EST

    Hello,


    I wanted to let you know we are still looking into the changes needed to be made. I got the SubEditor to pass the keystrokes to the editor but I am getting an exception when chioosing an item in the list. This is because it is causing the EditChange event to fire and you have code to reshow the SubEditor. I have sent this to a developer to help find the best way to implement this. I will let you know as soon as I hear something.

  • Replied 8 September 2017, 1:43 pm EST

    Can you create a small sample project containing your custom cell type class with some minimal code to initialize one and use it in the Spread?  We will be able to help you much better if we know more details about what you are doing, and we can debug your code here with the latest release.
  • Replied 8 September 2017, 1:43 pm EST

    Hello,

    I have attached a zip of a simple project which recreates the issue. You help is greatly appreciated.

     

    Thanks,

    Lee

     


    2009/01/WindowsApplication2.zip
  • Replied 8 September 2017, 1:43 pm EST

    Lee,


    Painting the button is an easy issue to fix. You need to pass in the correct rectangle to the DrawComboButton method.


    Dim buttonRect As New Rectangle(r.X + r.Width - SystemInformation.VerticalScrollBarWidth, r.Y, SystemInformation.VerticalScrollBarWidth, r.Height)


    ControlPaint.DrawComboButton(g, buttonRect, ButtonState.Normal)


    For the issue of the Spread not getting keystrokes anymore, this is much more involved. We have changed the Owner of the SubEditor being created between versions from the Spread to the desktop. This solved issues with the subeditor being clipped if it was drawn near Spread borders. However now the keystokes are not being passed to the Spread to process before the SubEditor. We wanted it this way so some controls like drop down calenders would process arrow keys to move the date instead of the Spread getting the arrow and moving cells.


    Now, you can catch the keystroke, like you are doing and do whatever you want with it. If you implement ISubEditoParentInfo on your SubEditor, then you woud have a property (EditorControl) that you can use to get to the editing control that created the SubEditor. Then you can pass the keystroke to the Editor for normal processing.

  • Replied 8 September 2017, 1:43 pm EST

    Thank you.
  • Replied 8 September 2017, 1:43 pm EST

    Hello,


    The developer found the issue to be with your code in the EditChange event reopening the SubEditor. This event is firing when the ValueChanged event of the SubEditor is firing as the SubEditor is being closed. However, the SubEditor being opened (by your code in the EditChange event) is causing the exception. I worked around this in your code by putting a global flag that I check before opening the SubEditor in the EditChange. I set/unset this flag in the SubEditorOpening and SubEditorClosing events. I have attached the project sent with the changes I made to get it working.


    2009/02/WindowsApplication2.zip
Need extra support?

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

Learn More

Forum Channels