Adding a user control as a custom cell type

Posted by: jsh324 on 8 September 2017, 1:44 pm EST

  • Posted 8 September 2017, 1:44 pm EST

    I need to be able to create new row underneath a row that was clicked and add a custom user control into a cell in the new row.  How would I accomplish that?  I thought that I would need to add the user control as a custom cell type.  But I'm not quite sure if that's how or even how to do that.  Unfortunately, I'm new to Spread.  Any help would be greatly appreciated!

    Thanks.

  • Replied 8 September 2017, 1:44 pm EST

    Hello,

    Regarding your query, you may try using the AddRows method in response of the CellClick event of the Spread control.The first parameter of AddRows will take the position at which to add rows at and 2nd parameter number of rows to add.

      FpSpread1.ActiveSheet.AddRows(10, 2)

    The above snippet will add 2 rows at the 10th row position.And with regards to custom cell type, you may use the FarOut sample, that gets installed with the Spread(Spread for Windows Forms 4\samples folder) control to understand the intricacies of the Cell types.

     Thanks

    Suresh

  • Replied 8 September 2017, 1:44 pm EST

    Suresh,

     Thank you for your reply.  I'm able to now add rows.  However, I'm still not quite sure, after looking at the sample, how to add my own previously built custom user control to a row.  Could you provide a sample of how I could do that or direct me to where I may find another example?

     Thanks.

    J.

  • Replied 8 September 2017, 1:44 pm EST

    Hello,

    You may try using the SpreadChildControl sample, it demonstrates the implementation of the required behavior. I am attaching the same for your reference.

    Hope this helps.

    Thanks,

    Suresh


    2009/02/SpreadChildControls.zip
  • Replied 8 September 2017, 1:44 pm EST

    J,


    What exactly do you want your custom control to do in the cell. Spread has two states for the cell (rendering and editing). Do you want your control to just paint in the cell, or do you want to use your control as the editor or both). Using the method Suresh has giving to you would be the way to implement this if you want to interact with your control outside of Spread. Just have Spread posistion the control and scroll the control for you on it's Drawing layer.


    If you want to embed your control into the Spread cell, you would need to create a custom celltype and override the PaintCell method to implement how you want Spread to paint the cell (out of editmode). And you would need to override the GetEditorControl to implement the editor to be used in the cell when it is editing. There are other methods that you would also need to override depending on what you want to do exactly.

  • Replied 8 September 2017, 1:44 pm EST

    Scotts,

    I actually wanted to do both.  I did want to embed my control into the cell.  However, our requirements are changing.  So for the time being, I'm going to hold off on this development.  Thank you all for your help!

     Thanks!

     J.

Need extra support?

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

Learn More

Forum Channels