找回密码
 立即注册

QQ登录

只需一步,快速开始

我心飞翔qi

注册会员

8

主题

23

帖子

135

积分

注册会员

积分
135
我心飞翔qi
注册会员   /  发表于:2019-6-14 10:48  /   查看:3402  /  回复:5
C1GanttView1是否支持数据绑定功能,在例子databinding中有显示使用dataset绑定C1GanttView1的功能,请教是否可以通过代码直接用dataset或datatable绑定C1GanttView1,我设置字段映射 的代码是:        C1GanttView1.DataStorage.CalendarStorage.Mappings.Name.MappingName = "Name"        C1GanttView1.DataStorage.CalendarStorage.Mappings.Data.MappingName = "Data",但C1GanttView1不成功。不知道有没有什么好方法。

5 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-14 11:41:07
沙发
支持数据绑定,可以参考这个绑定字段
https://help.grapecity.com/compo ... ame.html#Step3.html

你说的不成功的原因,我现在无法确定,方便的话可以将代码打包发上来
回复 使用道具 举报
我心飞翔qi
注册会员   /  发表于:2019-6-14 11:54:14
板凳
    Dim cn As New OleDbConnection
        

        Dim dd1 As New DataSet
        Dim dd2 As New DataSet
        Dim dd3 As New DataSet
        Dim dd4 As New DataSet

        Dim ds As New DataSet
        C1GanttView1.Tasks.Clear()

        Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\甘特图测试\甘特图数据\C1NWind.mdb;"
        cn.ConnectionString = cnStr

        cn.Open()



        Dim casql As String = " select * from Calendars "
        Dim prsql As String = " select * from properties "
        Dim resql As String = " select * from resources "
        Dim taskssql As String = " select * from tasks "
        Dim da1 As OleDbDataAdapter = New OleDbDataAdapter(casql, cn)
        Dim da2 As OleDbDataAdapter = New OleDbDataAdapter(prsql, cn)
        Dim da3 As OleDbDataAdapter = New OleDbDataAdapter(resql, cn)
        Dim da4 As OleDbDataAdapter = New OleDbDataAdapter(taskssql, cn)

        da1.Fill(dd1)
        da2.Fill(dd2)
        da3.Fill(dd3)
        da4.Fill(dd4)
        cn.Close()
        Dim db As New DBDataTable

      

        Dim tb1 As DataTable = dd1.Tables(0)
        Dim tb2 As DataTable = dd2.Tables(0)
        Dim tb3 As DataTable = dd3.Tables(0)
        Dim tb4 As DataTable = dd4.Tables(0)
        C1GanttView1.DataStorage.CalendarStorage.DataSource = tb1

        C1GanttView1.DataStorage.CalendarStorage.RefreshData()
        C1GanttView1.DataStorage.PropertyStorage.DataSource = tb2
        C1GanttView1.DataStorage.ResourceStorage.DataSource = tb3
        C1GanttView1.DataStorage.ResourceStorage.RefreshData()
        C1GanttView1.DataStorage.TasksStorage.DataSource = tb4

        C1GanttView1.DataStorage.TasksStorage.RefreshData()
      
        C1GanttView1.DataStorage.CalendarStorage.Mappings.IdMapping.MappingName = "Id"
        C1GanttView1.DataStorage.CalendarStorage.Mappings.CalendarID.MappingName = "CalendarID"
        C1GanttView1.DataStorage.CalendarStorage.Mappings.Name.MappingName = "Name"
        C1GanttView1.DataStorage.CalendarStorage.Mappings.Data.MappingName = "Data"

        C1GanttView1.DataStorage.PropertyStorage.Key.MappingName = "Key"
        C1GanttView1.DataStorage.PropertyStorage.Value.MappingName = "Value"

        C1GanttView1.DataStorage.ResourceStorage.Mappings.IdMapping.MappingName = "Id"
        C1GanttView1.DataStorage.ResourceStorage.Mappings.ResourceID.MappingName = "ResourceID"
        C1GanttView1.DataStorage.ResourceStorage.Mappings.Name.MappingName = "Name"
        C1GanttView1.DataStorage.ResourceStorage.Mappings.Notes.MappingName = "Notes"
        C1GanttView1.DataStorage.ResourceStorage.Mappings.ResourceType.MappingName = "ResourceType"
        C1GanttView1.DataStorage.ResourceStorage.Mappings.Cost.MappingName = "Cost"
        C1GanttView1.DataStorage.ResourceStorage.Mappings.UnitOfMeasure.MappingName = "UnitOfMeasure"


        C1GanttView1.DataStorage.TasksStorage.Mappings.IdMapping.MappingName = "Id"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Initialized.MappingName = "Initialized"
        C1GanttView1.DataStorage.TasksStorage.Mappings.TaskID.MappingName = "TaskID"
        C1GanttView1.DataStorage.TasksStorage.Mappings.NextID.MappingName = "NextID"
        C1GanttView1.DataStorage.TasksStorage.Mappings.OutlineParentID.MappingName = "OutlineParentID"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Summary.MappingName = "Summary"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Name.MappingName = "Name"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Start.MappingName = "Start"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Finish.MappingName = "Finish "
        C1GanttView1.DataStorage.TasksStorage.Mappings.Duration.MappingName = "Duration"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Mode.MappingName = "Mode"
        C1GanttView1.DataStorage.TasksStorage.Mappings.CalendarID.MappingName = "CalendarID"
        C1GanttView1.DataStorage.TasksStorage.Mappings.DurationUnits.MappingName = "DurationUnits"
        C1GanttView1.DataStorage.TasksStorage.Mappings.PercentComplete.MappingName = "PercentComplete"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Deadline.MappingName = "Deadline"
        C1GanttView1.DataStorage.TasksStorage.Mappings.ConstraintType.MappingName = "ConstraintType"
        C1GanttView1.DataStorage.TasksStorage.Mappings.ConstraintDate.MappingName = "ConstraintDate"
        C1GanttView1.DataStorage.TasksStorage.Mappings.HideBar.MappingName = "HideBar"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Predecessors.MappingName = "Predecessors"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Resources.MappingName = "Resources"
        C1GanttView1.DataStorage.TasksStorage.Mappings.CustomFields.MappingName = "CustomFields"
        C1GanttView1.DataStorage.TasksStorage.Mappings.Notes.MappingName = "Notes"

这是我的加载数据的代码,麻烦您帮看一下

回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-14 14:49:31
地板
通过代码绑定肯定是可以的,你在设计器里进行的操作,最后也是会以代码的形式存储在Form1.Designer.vb中,既然你在看这里例子,我建议你就直接参考他的Designer.vb中的相关代码,

从你发的代码来看没有什么问题,但是你只给我发部分代码我还是没法判断你的问题错误在哪里,C1GanttView1不成功是什么意思呢
回复 使用道具 举报
我心飞翔qi
注册会员   /  发表于:2019-6-17 10:25:51
5#
已经弄好了,主要是要先映射之后再给 FILL 数据
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2019-6-17 11:59:05
6#
嗯,好的
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部