Adding a column to a Farpoint Spread grid

4.7k Views Asked by At

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
2

There are 2 best solutions below

0
On

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

13
On

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.