msflexgrid允许大选择_MsFlexGrid用法大全(转)

作者:中国论坛网收集 来源:http://www.51one.net 加入时间:2004-8-25

在VB处理数据显示的时候,使用表格是一种好的方法,虽然DataGrid可以与数据源绑定,但是总有美中不足,就是

外观不好看,所以有时应用MsFlexGrid显示数据还是一种比较好的方法,以下几个函数是用来控制MsFlexGrid的

程序

(本人语言表达能力有限,还请见谅)

''MsFlexGrid操作函数

''合并列

Public Function MergeCol(GridObj As Object, ByVal StartCol As Long, ByVal EndCol As Long, ByVal

ColValue As String, ByVal CurrentRow As Long) As Boolean

If StartCol &gt EndCol Or StartCol &gt GridObj.Cols Or CurrentRow &gt GridObj.Rows Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

MergeCol = False

Exit Function

End If

For I = StartCol To EndCol

GridObj.MergeCol(I) = True

GridObj.TextArray(faIndex(GridObj, CurrentRow, I)) = ColValue

GridObj.ColAlignment(I) = flexAlignCenterCenter

Next I

GridObj.MergeRow(CurrentRow) = True

MergeCol = True

End Function

''合并行

Public Function MergeRow(GridObj As Object, ByVal StartRow As Long, ByVal EndRow As Long, ByVal

RowValue As String, ByVal CurrentCol As Long) As Boolean

If StartRow &gt EndRow Or StartRow &gt GridObj.Rows Or CurrentCol &gt GridObj.Cols Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

MergeRow = False

Exit Function

End If

For I = StartRow To EndRow

GridObj.MergeRow(I) = True

GridObj.TextArray(faIndex(GridObj, I, CurrentCol)) = RowValue

GridObj.ColAlignment(CurrentCol) = flexAlignCenterCenter

Next I

GridObj.MergeCol(CurrentCol) = True

MergeRow = True

End Function

''转换索引

Public Function faIndex(GridObj As Object, ByVal row As Integer, ByVal col As Integer) As Long

If row &gt GridObj.Rows Or row &lt 0 Or col &gt GridObj.Cols Or col &lt 0 Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

faIndex = -1

Exit Function

End If

faIndex = row * GridObj.Cols + col

End Function

''插入行

Public Function SetItem(GridObj As Object, ByVal row As Integer, ByVal col As Integer, ByVal

SetValue As String) As Boolean

If row &gt GridObj.Rows Or row &lt 0 Or col &gt GridObj.Cols Or col &lt 0 Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

SetItem = False

Exit Function

End If

GridObj.TextArray(faIndex(GridObj, row, col)) = SetValue

SetItem = True

End Function

''得到单元格值

Public Function GetItem(GridObj As Object, ByVal row As Integer, ByVal col As Integer) As String

If row &gt GridObj.Rows Or row &lt 0 Or col &gt GridObj.Cols Or col &lt 0 Then

MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title

GetItem = ""

Exit Function

End If

GetItem = GridObj.TextArray(faIndex(GridObj, row, col))

End Function

在msflexgrid控件中每一个cell格的内容是不可以由用户直接编辑的但是我们可以通过一些小技

巧来方便的实现这编辑功能来扩展msflexgrid

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值