找回密码
 立即注册

QQ登录

只需一步,快速开始

g7598059g

初级会员

2

主题

9

帖子

485

积分

初级会员

积分
485

活字格认证

最新发帖
g7598059g
初级会员   /  发表于:2012-6-14 09:28  /   查看:12043  /  回复:12
FarPoint.Web.Spread.ComboBoxCellType combox = new  FarPoint.Web.Spread.ComboBoxCellType();
上面的是C#中的定义  

在vb中不识别呀,下面是我写的vb定义
Dim combox As FarPoint.Win.Spread.ComboBoxCellType = New FarPoint.Win.Spread.ComboBoxCellType()   
版主帮忙看看错在那里

12 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-6-14 09:44:00
沙发
回复 1楼g7598059g的帖子

VB.NET的代码如下:
  1.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  2.         Dim cbstr As String()
  3.         cbstr = New String() {"Jan", "Feb", "Mar", "Apr", "May", "Jun"}
  4.         Dim cmbocell As New FarPoint.Win.Spread.CellType.ComboBoxCellType()
  5.         cmbocell.Items = cbstr

  6.         FpSpread1.ActiveSheet.Columns(0).CellType = cmbocell
  7.     End Sub
复制代码


在Spread for WinForms 6.0帮助文档中,都同时给出了C#和VB.NET的代码,你也可以参考。
回复 使用道具 举报
g7598059g
初级会员   /  发表于:2012-6-14 11:36:00
板凳
回复 2楼dof的帖子

  //设置单元格为下拉框
            FarPoint.Web.Spread.ComboBoxCellType combox = new FarPoint.Web.Spread.ComboBoxCellType();
//绑定下拉框数据源
            combox.AllowWrap = true;
            combox.DataSource = dtDropDownSouce;
            combox.ShowButton = true;
            combox.DataTextField = "NAME";
            combox.DataValueField = "VALUES";
            combox.UseValue = true;
            combox.AutoPostBack = true;

用这个怎么点不出来上面那些属性呢,vb中只能给它绑定数组吗
Dim cmbocell As New FarPoint.Win.Spread.CellType.ComboBoxCellType()
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-6-14 12:28:00
地板
回复 3楼g7598059g的帖子

从你的代码俩看,你同时使用了FarPoint.Web.Spread和FarPoint.Win.Spread,这时Spread两个不同产品的命名空间,请问你现在时开发的WinForms程序还是ASP.NET程序呢。
回复 使用道具 举报
g7598059g
初级会员   /  发表于:2012-6-14 13:06:00
5#
回复 4楼dof的帖子

FarPoint.Web.Spread 这个是asp。net中的代码   

我现在做的是winforms,参考以前asp。net的代码

呵呵 才学这个控件  版主见笑了
回复 使用道具 举报
g7598059g
初级会员   /  发表于:2012-6-14 13:22:00
6#
//设置单元格为下拉框
         FarPoint.Web.Spread.ComboBoxCellType combox = new FarPoint.Web.Spread.ComboBoxCellType();
           //构建数据源
         DataTable dtDropDownSouce = new DataTable();
            dtDropDownSouce.Columns.AddRange(new DataColumn[] { new DataColumn("NAME", typeof(string)), new DataColumn("VALUES", typeof(string)) });

            for (int i = 0; i < enumValues.Length; i++)
            {
                dtDropDownSouce.Rows.Add(new object[] { enumValues.GetValue(i), enumValues.GetValue(i) });
            }

            //绑定下拉框数据源
            combox.AllowWrap = true;
            combox.DataSource = dtDropDownSouce;
            combox.ShowButton = true;
            combox.DataTextField = "NAME";
            combox.DataValueField = "VALUES";
            combox.UseValue = true;
            combox.AutoPostBack = true;

            //设置单元格类型
            FpSpread1.Sheets[spreadSheetIndex].Cells[spreadRowIndex, spreadColumnIndex].CellType = combox;

————————————————————————————————————————————————————————————————————

            '设置单元格为下拉框
        Dim combox As New FarPoint.Win.Spread.CellType.ComboBoxCellType()

            '绑定下拉框数据源
        Dim cbstr As String() = New String() {}
            For i As Integer = 0 To enumValues.Length - 1
            cbstr.SetValue(enumValues.GetValue(i), i)
            Next
            combox.Items = cbstr

            '设置单元格类型
        FpSpread1.Sheets(spreadSheetIndex).Cells(spreadRowIndex, spreadColumnIndex).CellType = combox

上下两块代码是表达的意思一样么?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-6-14 14:19:00
7#
回复 6楼g7598059g的帖子
哈哈,我只是想弄清楚你的开发平台而已,然后给出相应的代码

以上代码功能不完全一样,上面部分的代码ComboBoxCellType显示的是name,而返回的值确实Values

在WinForms中可以结合Items和ItemData来实现类似的功能

  1.         Dim cbstr As String()
  2.         cbstr = New String() {"One", "Two", "Three"}
  3.         Dim strval As String()
  4.         strval = New String() {"1", "2", "3"}
  5.         combo.Items = cbstr
  6.         combo.ItemData = strval
  7.         combo.EditorValue = FarPoint.Win.Spread.CellType.EditorValue.ItemData
  8.         FpSpread1.Sheets(0).Cells(0, 0).CellType = combo
复制代码
回复 使用道具 举报
g7598059g
初级会员   /  发表于:2012-6-14 14:33:00
8#
回复 7楼dof的帖子

呵呵 非常感谢版主滴耐心指导   思路现在清晰多了

还有个小问题就是在WinForms中FpSpread1。Save()必须传2个参数,但在asp.net中直接SaveChanges就可以了,请问怎么解决呀
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-6-14 16:10:00
9#
Save方法是将Spread保存为Stream或者本地文件,而SaveChanges是在ASP.NET中将客户端修改的数据同步到服务端中的Spread里,所以,两个方法的作用是不一样的。
两个方法的作用和使用方法你可以先查看文档。
回复 使用道具 举报
g7598059g
初级会员   /  发表于:2012-6-14 17:25:00
10#
:-|  文档在那里呢。。版主我小白饿
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部