找回密码
 立即注册

QQ登录

只需一步,快速开始

tianyake

注册会员

23

主题

58

帖子

183

积分

注册会员

积分
183

活字格认证

tianyake
注册会员   /  发表于:2014-5-22 17:27  /   查看:14057  /  回复:12
spread绑定数据,在datafill事件中,设置当某一列的单元格为空时,该单元格格式button

Private Sub fpSpreadRpt_DataFill(ByVal Col As Long, ByVal Row As Long, ByVal DataType As Integer, ByVal fGetData As Integer, Cancel As Integer)

If Col = 3 Then
    If fpSpreadRpt.GetText(3, Row, m_Data) Then
        If m_Data = "" Then
            With fpSpreadRpt
                .Col = 3
                .Col2 = 3
                .Row = Row
                .Row2 = Row
                .CellType = CellTypeButton
            End With
        End If
    End If
End If
End Sub


但是该列并不显示Button,请教一下为什么,如何往下

12 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-6-18 20:14:00
推荐
回复 13楼tianyake的帖子

抱歉,让你久等了。
需要通过 GetDataFillData 方法来获取当前绑定单元格的数据,获取方法如下:

  1. Private Sub ss_DataFill(ByVal Col As Long, ByVal Row As Long, ByVal DataType As Integer, ByVal fGetData As Integer, Cancel As Integer)

  2. If Col = 3 Then
  3.     Dim v As Variant
  4.     If ss.GetDataFillData(v, DataType) Then
  5.         If v = "" Then
  6.             With ss
  7.                 .Col = 3
  8.                 .Col2 = 3
  9.                 .Row = Row
  10.                 .Row2 = Row
  11.                 .CellType = CellTypeButton
  12.             End With
  13.         End If
  14.     End If
  15. End If
复制代码


Demo:

DataFill.zip (14.72 KB, 下载次数: 344)
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-5-23 18:23:00
沙发
回复 1楼tianyake的帖子

请你尝试通过以下方法设置,看能否成功:

  1. ' Specify a cell
  2. fpSpread1.Col = 2
  3. fpSpread1.Row = 3
  4. ' Define cell type as button
  5. fpSpread1.CellType = CellTypeButton
  6. ' Insert picture in the cell
  7. fpSpread1.TypeButtonPicture = LoadPicture("C:\Samples\Files\CAMCORD.BMP")
  8. ' Set button text
  9. fpSpread1.TypeButtonText = "Manufacturer"
  10. ' Define the text color
  11. ' dark blue, RGB(0, 0, 128)
  12. fpSpread1.TypeButtonTextColor = &H800000
  13. ' Align text right and picture left
  14. fpSpread1.TypeButtonAlign = TypeButtonAlignRight
  15. ' Set the column width to display text and picture
  16. fpSpread1.ColWidth(2) = 15
  17. ' Set the row height to display entire picture
  18. fpSpread1.RowHeight(3) = 20

复制代码
回复 使用道具 举报
tianyake
注册会员   /  发表于:2014-5-23 21:24:00
板凳
单独设置某一个单元格为Button是没有问题的,但是在DataFill事件中设置是没有效果的

我现在就是想在绑定的时候根据数据来确定是否显示为Button
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-5-26 17:21:00
地板
回复 3楼tianyake的帖子

我通过附件使用 Spread Com 8.0 可以成功设置 ButtonCellType :

DataFill.zip (9.83 KB, 下载次数: 799)
回复 使用道具 举报
tianyake
注册会员   /  发表于:2014-5-27 12:05:00
5#
发现问题在于datafill中

fpSpreadRpt.GetText(3, Row, m_Data)总等于false


如何在datafill中取单元格的值?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-5-27 17:30:00
6#
回复 5楼tianyake的帖子

我是通过以下代码获取的:

  1. fpSpreadRpt.Row=1
  2. fpSpreadRpt.Col=2
  3. Dim test As String
  4. test = fpSpreadRpt.Text
复制代码
回复 使用道具 举报
tianyake
注册会员   /  发表于:2014-5-29 08:41:00
7#
你理解错了,单独这么取值肯定可以取得到的,而且不是上像你这么取一个特定的单元格

我现在是要在datafill事件中,绑定单元格时,取该单元格的值

我要到达的目的是,绑定第三列时,如果第三列某行的值为空,则设置该单元格为button,请看我原贴代码
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-5-29 11:32:00
8#
回复 7楼tianyake的帖子

您好,这个帖子沟通了4轮了,为了快速解决您的问题。

能否给提供一个demo,这样我们沟通起来效率可能会更高一些。 如可基于4#的demo。
回复 使用道具 举报
tianyake
注册会员   /  发表于:2014-6-3 16:33:00
9#
好的,请参照附件,谢谢

DataFill.rar (8.94 KB, 下载次数: 364)
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-6-4 17:08:00
10#
回复 9楼tianyake的帖子

附件已经查收,调试后反馈结果。
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部