首 页文章中心下载中心繁體中文
设为首页
加入收藏
联系我们
您当前的位置:开源盛世-源代码下载网 -> 文章中心 -> V B 专区 -> 文章内容 退出登录 用户管理
投票调查
栏目导航
· VC++专区 · V B 专区
· GIS 专区 · PDA 专区
· 其他编程 · 网站开发类
· 数据库类 · 软件应用
· 网络安全 · 论文专区
· 综合资讯
热门文章
· Tab Control控件使用...
· 学生档案管理系统
· [图文] 排列组合公式
· UTF-8与GB2312之间的...
· DirectShow下载安装...
· Virtual PC 在PAE模...
· Windows2000终端服务...
· MapInfo上的GIS系统...
· kalman filter 卡尔...
· Windows2000终端服务...
相关文章
· 为何我在asp程序内使...
使用MsFlexGrid控件的几个函数
作者:佚名  来源:vscodes.com整理  发布时间:2005-12-16 13:42:32  发布人:Polaris

减小字体 增大字体

在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 > EndCol Or StartCol > GridObj.Cols Or CurrentRow > 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 > EndRow Or StartRow > GridObj.Rows Or CurrentCol > 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 > GridObj.Rows Or row < 0 Or col > GridObj.Cols Or col < 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 > GridObj.Rows Or row < 0 Or col > GridObj.Cols Or col < 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 > GridObj.Rows Or row < 0 Or col > GridObj.Cols Or col < 0 Then
    MsgBox "对不起,行列设置错误!", vbOKOnly, App.Title
    GetItem = ""
    Exit Function
End If
    GetItem = GridObj.TextArray(faIndex(GridObj, row, col))
End Function



这是我以前写的几个函数,不知能不能帮上你, 我弄Excel时间挺长,有什么问题可以给我发E_mail

w.hua@ynmail.com


End of《使用MsFlexGrid控件的几个函数》

[] [返回上一页] [打 印] [收 藏]
 
∷相关“使用MsFlexGrid控件的几个函数”文章评论∷
(评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站目录 鄂ICP备06007162
开源盛世 版权所有Copyright © 2003-2005 VSCodes.Com. All Rights Reserved.