0

I've never really used Farpoint Spread before, but I have an existing VB.NET application in which I need to add a column to a Spread grid. There is currently some code like:

For Each dr As DataRow In g_AdoRS.Rows
    vaSpreadSum.SetText(1, x, dr(0))    'pol_ser
    ...
    vaSpreadSum.SetText(20, x, dr(19))    'renew_pay_cd     
    vaSpreadSum.SetFloat(21, x, dr(20))    'renew_tot_prem
    vaSpreadSum.SetFloat(22, x, dr(21))    'renew_pol_limit
    vaSpreadSum.SetFloat(23, x, dr(22))    'renew_ded_amt

    vaSpreadSum.Col = 28
    x = x + 1
Next dr

These SetFloat() and SetText() calls go from 0 to 28. So in order to add another column I added this line of code:

vaSpreadSum.SetText(28, x, dr(27))    'agent name

and changed the vaSpreadSum.Col to 29

vaSpreadSum.Col = 29

But I am not seeing another column in my grid. Any idea why? There is no error thrown or anything like that, just no changes on the screen. I know there is probably more information needed to solve this, but even if anyone know the basics of adding a column to a Farpoint Spread grid that would be much appreciated. I found this but it doesn't seem that my application is adding columns that way, I couldn't find any calls to the AddColumns() method anywhere.

Thanks for any help!

I believe this is my Form_Load method

Private Sub FrmDetailRPC_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
    Cursor.Current = Cursors.WaitCursor

    FormInit()
    QryLocation()

    Cursor.Current = Cursors.Default
End Sub

I'll also include FormInit() because that sounds like it might have to do with what I'm looking for

Sub FormInit()
    txtBusUnit.Text = svBusUnit
    stmtMktSeg()
    txtProduct.Text = svProduct
    txtSource.Text = svSource
    txtSystem.Text = svSystem
    txtCustSeg.Text = svCustSeg

    stmtProduct()

    txtLocation.Text = svLocation
    If svLocationLabel = "Region" Then
        lblLocation.Text = "Territory"
    Else
        lblLocation.Text = svLocationLabel
    End If

    lblLocation.TextAlign = ContentAlignment.TopRight

    stmtLocation()
    'txtPayType.Text = svPayType
    txtTimePer.Text = TimeName
    stmtTimePer()

End Sub

And QryLocation()

Sub QryLocation()
    Dim producerID As String

    'SetProductSelection()
    stmtLocation()
    stmtGetProductType()
    stmtGetTimePeriodType()
    stmtGetTimePeriod()
    stmtGetProducerID()
    stmtGetProducerType()

    If stmtProducerType = "No Preference" Then
        producerID = "NULL"
    Else
        producerID = "'" & stmtProducerID & "'"
    End If

    g_strSQL = "pc_mis_rpc_getdata_detail " & _
    "'" & stmtLocationType & "'," & _
    "'" & Trim(svLocation) & "'," & _
    "'" & svBusUnit & "'," & _
    "'" & stmtProductType & "'," & _
    "'" & Trim(stmtProductDtl) & "'," & _
    "'" & stmtTimePeriod & "'," & _
    "'" & stmtTimePeriodType & "'," & _
    "'" & stmtProducerType & "'," & _
    producerID & "," & _
    "'Retention'" _
    & FilterQry & "," & _
    "'" & Trim(txtCustSeg.Text) & "'," & _
    "'" & Trim(txtSource.Text) & "'," & _
    "'" & Trim(txtSystem.Text) & "'"


    ProcQry()

End Sub
intA
  • 2,513
  • 12
  • 41
  • 66
  • Do you know if the grid was created with the designer originally? If so, there should be something in the form's generated code that tells the spread control how many columns and rows exist. You can also look at the form designer, click on the spread control, hit F4 to see properties for the control, and check to see if rows and columns are defined there. – Adam Zuckerman Feb 22 '14 at 02:32
  • I'm not sure if it was made with the designer, I don't have access to it apparently, since I only have the standard license. I added a lot of the code that I think generates the grid to my post above. – intA Feb 24 '14 at 18:43
  • That code does not change the number of columns. It is only for when a click occurs in the spreadsheet. Would you post your Form_Load code please? – Adam Zuckerman Feb 24 '14 at 19:14
  • There is no method exactly called "Form_Load" but I believe what I added to my original post is what you're referring to. – intA Feb 24 '14 at 19:31
  • Would you also post FormInit and QryLocation too please? – Adam Zuckerman Feb 24 '14 at 19:33
  • Done. Sorry, should have figured those would be important. – intA Feb 24 '14 at 19:36
  • I am not seeing what I am looking for. I think I know the correct syntax. Let me add the answer now. – Adam Zuckerman Feb 24 '14 at 19:38

2 Answers2

0

In your Form_Init() you will need to adjust the number of columns in spread control.

It should look something like this:

Sub FormInit()
    ' Add a column to the spreadsheet control
    vaSpreadSum.ActiveSheet.AddColumns(29, 1)

    ' Code cut for brevity
End Sub

--or--

Sub FormInit()
    ' Add a column to the spreadsheet control
    vaSpreadSum.ActiveSheet.Columns.Count = 29

    ' Code cut for brevity
End Sub

Another method for achieving the same thing is to open the form designer, select the spread control, display the properties window (press F4 if it isn't already open), and increase the Cols property to 29.

Adam Zuckerman
  • 1,633
  • 1
  • 14
  • 20
  • Says 'Cols is not a member of AxFPSpreadADO.AxfpSpread' 'Col' seems to not throw an error, think its the same? – intA Feb 24 '14 at 19:47
  • Just tried it with Col and it gave me a null reference exception – intA Feb 24 '14 at 19:49
  • No. Try Columns instead of Cols. I don't have the documentation in front of me so I am trying to remember what the correct property name should be. – Adam Zuckerman Feb 24 '14 at 19:49
  • Doesn't like Columns or Column either. Is there documentation for this? I've been looking all over and haven't been able to find any. – intA Feb 24 '14 at 19:51
  • http://helpcentral.componentone.com/NetHelp/SpreadNet7/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.SheetView~AddColumns.html – Adam Zuckerman Feb 24 '14 at 19:53
  • Yeah, I've been there. I guess I'm just not sure where to go from there. Nothing looks familiar... – intA Feb 24 '14 at 19:54
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/48301/discussion-between-adam-zuckerman-and-inta) – Adam Zuckerman Feb 24 '14 at 19:59
  • Sorry, I had to get up for a bit. Also, I'm at work and can't access the chat. I will let you know how this new code goes when I try it in a minute. – intA Feb 24 '14 at 20:33
  • I get an error with both, saying either "'AddColumns' is not a member of 'Short'" or "'Columns' is not a member of 'Short'" Col or Cols also does not work. – intA Feb 24 '14 at 20:40
  • Did you try opening the form designer? – Adam Zuckerman Feb 24 '14 at 21:21
  • Yeah. I cannot see the grid within the form designer. I imagine that's what the Farpoint designer would be used for. – intA Feb 24 '14 at 22:57
  • Do you want me to look at the whole form? You could email it to me. I'll add my email to my profile's About Me if you want to do that. – Adam Zuckerman Feb 24 '14 at 23:02
  • Looks like I'm going to be getting access to the designer so that should hopefully solve my problem. Thank you for all your help, it is much appreciated! – intA Feb 25 '14 at 15:44
0

You increase the column as follows: vaSpreadSum.MaxCols = 29

Murphie
  • 29
  • 3