原創(chuàng)|其它|編輯:郝浩|2012-11-27 09:39:51.000|閱讀 332 次
概述:在Spread Windows Forms中手動(dòng)創(chuàng)建分級(jí)顯示的使用教程,附加源。在本文中將會(huì)創(chuàng)建兩個(gè)自定義的SheetView對(duì)象,一個(gè)作為父級(jí),一個(gè)作為子級(jí)
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在本文中將會(huì)創(chuàng)建兩個(gè)自定義的SheetView對(duì)象,一個(gè)作為父級(jí),一個(gè)作為子級(jí)。在父級(jí)中重寫了ChildRelationCount 和 GetChildView 和 FindChildView 方法,ChildRelationCount顯示著對(duì)象和子對(duì)象之間多少的關(guān)系,GetChildView則是備用來(lái)看看是否創(chuàng)建了工作表格,如果是應(yīng)經(jīng)創(chuàng)建了,那么就使用這一個(gè),如果沒(méi)有,就重新再創(chuàng)建一個(gè)新的子表格,子SheetView決定著表格名字屬性分配給哪一個(gè)父級(jí)行,然后在子SheetView中覆蓋arentRowIndex的屬性來(lái)返回子表格所屬于的行號(hào),而創(chuàng)建這個(gè)表的SheetName決定了這個(gè)數(shù)字。
所用到的代碼如下:
VB:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load FpSpread1.Sheets.Clear() FpSpread1.Sheets.Add(New customSheet) FpSpread1.Sheets(0).RowCount = 10 Dim i As Integer For i = 0 To 9 If i <> 1 Then FpSpread1.Sheets(0).SetRowExpandable(i, False) End If Next i End Sub End Class Public Class customSheet Inherits FarPoint.Win.Spread.SheetView Public Overrides ReadOnly Property ChildRelationCount() As Integer Get Return 1 End Get End Property Public Overrides Function GetChildView(ByVal row As Integer, ByVal relationIndex As Integer) As FarPoint.Win.Spread.SheetView Dim child As customChild = CType(FindChildView(row, 0), customChild) If Not (child Is Nothing) Then Return child child = New customChild child.RowCount = 5 child.Parent = Me child.SheetName = row.ToString ChildViews.Add(child) Return child End Function Public Overrides Function FindChildView(ByVal row As Integer, ByVal relationIndex As Integer) As FarPoint.Win.Spread.SheetView Dim id As String = row.ToString Dim View As FarPoint.Win.Spread.SheetView For Each View In ChildViews If View.SheetName = id Then Return View Next Return Nothing End Function End Class Public Class customChild Inherits FarPoint.Win.Spread.SheetView Public Overrides ReadOnly Property ParentRowIndex() As Integer Get Return CInt(SheetName) End Get End Property End Class
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件