彩票走势图

如何在Spread Windows Forms中手动的创建分级显示

原创|其它|编辑:郝浩|2012-11-27 09:39:51.000|阅读 293 次

概述:在Spread Windows Forms中手动创建分级显示的使用教程,附加源。在本文中将会创建两个自定义的SheetView对象,一个作为父级,一个作为子级

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

在本文中将会创建两个自定义的SheetView对象,一个作为父级,一个作为子级。在父级中重写了ChildRelationCount 和 GetChildView 和 FindChildView 方法,ChildRelationCount显示着对象和子对象之间多少的关系,GetChildView则是备用来看看是否创建了工作表格,如果是应经创建了,那么就使用这一个,如果没有,就重新再创建一个新的子表格,子SheetView决定着表格名字属性分配给哪一个父级行,然后在子SheetView中覆盖arentRowIndex的属性来返回子表格所属于的行号,而创建这个表的SheetName决定了这个数字。

所用到的代码如下:

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

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn

文章转载自:慧都控件

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP