最近想用fpspread控件,但是发现其给单元格赋值/读取时,每次需要定位,也就是需要设置其当前行列号,如下所示:
fpSpread1.Col = 1
fpSpread1.Row = 1
fpSpread1.Value = "2.22"想到MSHFlexGrid的属性中有个textmatrix(n,m)的属性,想给fpspread添加个这样的属性,但我从来没有进行这方面的学习,不知道该如何操作,看了一些,没有找到答案,网络上也没有搜索我需要的结果。最好能够有详细的过程及代码,谢谢。

解决方案 »

  1.   


    '方法:
    setText(Col,Row,VarValue)
      

  2.   

    但是对应的getText似乎不太好用。
    谢谢提供这种方法,不知道还有没有更好的方法。
      

  3.   

    将控件写到类里面实现,然后加个方法,我先抛个砖头...'clsSpread
    private o_Spread as object
    '设置对象
    '取得对象
    '设置/读取值
    function TextMatrix(byval l_Row as long,byval l_Col as long,optional s_value as string) as string
    o_Spread.Col = l_Col 
    o_Spread.Row = l_Row 
    select case len(s_value)
    case 0
    case else
    o_Spread.Value = s_value
    end select
    '返回值
    TextMatrix = o_Spread.value
    end function
    '如果可以的话,还是将上面的函数分开感觉好些,但是为了和Flexgrid差不多,这样写可以实现
      

  4.   

    通常用通用方法实现
    public property Get SpreadValue( _
            byval spd as fpspread, _
            byval col as long,byval row as long _
            ) as variant
        with spd
            .col = col
            .row = row
            SpreadValue = .value
        end with
    end property
    public property Let SpreadValue( _
            byval spd as fpspread, _
            byval col as long,byval row as long, _
            byval RHS as variant)
        with spd
            .col = col
            .row = row
            .value = RHS
        end with
    end property'调用
    SpreadValue(fpSpread1,1,1) = "2.22"
    Debug.Print SpreadValue(fpSpared1,1,1)
      

  5.   

    注:通用方法放在 Module 中
      

  6.   

    Tiger_Zhao的方法简单实用,
    AisaC的方法,因为本人这方面的知识严重不足,没有看明白,不知道该如何实施?是在新建的控件中添加类模块还是象Tiger_Zhao的方法一样在调用Spread控件的工程中添加类模块?如何调用?
      

  7.   

    看来就用Tiger_Zhao的方法就行了。