2014-02-21 178 views
0

我從來沒有真正使用過Farpoint Spread,但我有一個現有的VB.NET應用程序,我需要將它添加到Spread網格中。目前像一些代碼:將列添加到Farpoint 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 
+0

你知道網格是否是最初由設計者創建的嗎?如果是這樣,表單的生成代碼中應該有一些東西來告訴擴散控制有多少列和行存在。您還可以查看錶單設計器,單擊展開控件,點擊F4查看控件的屬性,然後檢查行和列是否在那裏定義。 –

+0

我不確定它是否由設計師製作,顯然我沒有訪問它,因爲我只有標準許可證。我在上面的帖子中添加了很多我認爲生成網格的代碼。 – intA

+0

該代碼不會更改列的數量。只有在電子表格中發生點擊時纔會發生。你會發布你的Form_Load代碼嗎? –

回答

0

在你的Form_Init()你需要調整colu的數量mns在傳播控制。

它應該是這個樣子:

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尚未打開,請按F4),並將Cols屬性增加到29.

+0

說Cols不是AxFPSpreadADO.AxfpSpread的成員'Col'似乎沒有拋出錯誤,認爲它是一樣的? – intA

+0

剛剛與Col一起嘗試過,它給了我一個空引用異常 – intA

+0

No.嘗試列而不是Cols。我沒有在我面前的文檔,所以我想記住什麼是正確的屬性名稱。 –

0

您增加該列,如下所示: vaSpreadSum.MaxC ols = 29