将列添加到Farpoint Spread网格

时间:2014-02-21 18:49:30

标签: vb.net excel grid spread farpoint

我以前从未真正使用过Farpoint Spread,但我有一个现有的VB.NET应用程序,我需要在Spread网格中添加一列。目前有一些代码如下:

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

这些SetFloat()和SetText()调用从0到28.因此,为了添加另一列,我添加了这行代码:

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

并将vaSpreadSum.Col更改为29

vaSpreadSum.Col = 29

但我没有在网格中看到另一列。知道为什么吗?没有抛出任何错误或类似的东西,只是屏幕上没有任何变化。我知道可能需要更多的信息来解决这个问题,但即使有人知道将一个列添加到Farpoint Spread网格的基础知识,我也会非常感激。我发现this但似乎我的应用程序似乎没有添加列,我无法在任何地方找到对AddColumns()方法的任何调用。

感谢您的帮助!

我相信这是我的Form_Load方法

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

我还会包含FormInit(),因为这听起来可能与我正在寻找的内容有关

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

和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 个答案:

答案 0 :(得分:0)

Form_Init()中,您需要调整点差控制中的列数。

看起来应该是这样的:

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

    ' Code cut for brevity
End Sub

- 或 -

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

    ' Code cut for brevity
End Sub

实现相同目标的另一种方法是打开表单设计器,选择展开控件,显示属性窗口(如果它还没有打开则按F4),并将Cols属性增加到29。

答案 1 :(得分:0)

您按如下方式增加列: vaSpreadSum.MaxCols = 29