Problem when trying to add a spread control dynamically on the fly

Posted by: j2associates on 8 September 2017, 12:56 pm EST

  • Posted 8 September 2017, 12:56 pm EST

    Hello all,


    I am trying to add tab pages with embedded spread controls on the fly with code like the following: 

    With Me.TabControl1
    ' Create new tab page with spread control on it.

    .TabPages.Add(New TabPage("MyText"))

    With .TabPages(index).Controls
    .Add(New FpSpread())

    ' Setup embedded spread control.

    With DirectCast(.Item(0), FpSpread)
    .Name = "FpSpread" & index.ToString
    .DataSource = table
    AutoSizeColumns(.ActiveSheet)
    End With
    End With
    End
    With
    The problem is that the DataSource property is still Nothing after setting it.
    Thanks in advance for any ideas and/or suggestions!
  • Replied 8 September 2017, 12:56 pm EST

    I know the fpSpread is being created correctly because the Name property changes based upon the above code. Sorry, I forgot to note that in the first posting.
  • Replied 8 September 2017, 12:56 pm EST

    Hello all,


    For the benefit of others, I needed to add at least one SheetView to the FpSpread. Once I inserted the following line before I set the DataSource property, it worked perfectly. 

    .Sheets.Add(New FarPoint.Win.Spread.SheetView)
    .DataSource = table
     
Need extra support?

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

Learn More

Forum Channels