找回密码
 立即注册

QQ登录

只需一步,快速开始

chenfeng1029
金牌服务用户   /  发表于:2017-3-26 20:14  /   查看:3364  /  回复:5
1、我通过实例代码,引入c1.win.c1command时,会提示附件图示
2、
2.但是如果我直接拖控件c1toobar时,则不会保存能正常使用。
不知道这个是啥原因。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

5 个回复

倒序浏览
chenfeng1029
金牌服务用户   /  发表于:2017-3-26 20:34:11
沙发
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ch As C1CommandHolder = C1CommandHolder.CreateCommandHolder(Me)
        ' In this sample, we use a single event handler for all commands,
        ' and use a switch statement inside that handler to select the specific
        ' action. Alternatively, each command can be assigned its own Click
        ' event handler. Or, a mix of the two approaches is possible.
        AddHandler ch.CommandClick, New CommandClickEventHandler(AddressOf CommandClickHandler)
        ' use the image list for command images
        ch.ImageList = Me.ImageList1
        ' modern look:
        ch.LookAndFeel = LookAndFeelEnum.Office2003

        Dim mm As New C1MainMenu
        Me.Controls.Add(mm)
        ' For the main menu, its CommandHolder property should be set
        ' (this is not required for builds 1.0.20041.47 or later of C1Command).
        mm.CommandHolder = ch

        ' Main menu - File
        Dim mFile As C1CommandMenu = CType(ch.CreateCommand(GetType(C1CommandMenu)), C1CommandMenu)
        mFile.Text = "&File"
        mm.CommandLinks.Add(New C1CommandLink(mFile))

        ' create commands for file ops
        Dim cNew As C1Command = ch.CreateCommand()
        cNew.Text = "&New"
        ' UserData is arbitrary data associated with commands;
        ' In this example we use text labels to recognize specific commands
        ' in the single command handler. Alternatively, we could have commands
        ' as members of our class, and compare objects to recognize commands.
        cNew.UserData = "file_new"
        cNew.Shortcut = Shortcut.CtrlN
        cNew.ImageIndex = 1
        Dim cOpen As C1Command = ch.CreateCommand()
        cOpen.Text = "&Open"
        cOpen.UserData = "file_open"
        cOpen.Shortcut = Shortcut.CtrlO
        cOpen.ImageIndex = 0
        Dim cExit As C1Command = ch.CreateCommand()
        cExit.Text = "E&xit"
        cExit.UserData = "exit"
        cExit.Shortcut = Shortcut.CtrlX

        mFile.CommandLinks.Add(New C1CommandLink(cNew))
        mFile.CommandLinks.Add(New C1CommandLink(cOpen))
        mFile.CommandLinks.Add(New C1CommandLink)
        mFile.CommandLinks(mFile.CommandLinks.Count - 1).Text = "-"
        mFile.CommandLinks.Add(New C1CommandLink(cExit))

        ' Main menu - Window
        Dim mWindow As C1CommandMenu = CType(ch.CreateCommand(GetType(C1CommandMenu)), C1CommandMenu)
        mWindow.Text = "&Window"
        mm.CommandLinks.Add(New C1CommandLink(mWindow))

        Dim cNewWindow As C1Command = ch.CreateCommand()
        cNewWindow.Text = "New &Window"
        cNewWindow.UserData = "window_new"
        cNewWindow.Shortcut = Shortcut.CtrlW
        cNewWindow.ImageIndex = 2

        mWindow.CommandLinks.Add(New C1CommandLink(cNewWindow))

        ' For toolbars to be dockable/floatable, we must put them
        ' in a C1CommandDock:
        Dim dock As New C1CommandDock
        Me.Controls.Add(dock)
        dock.Dock = DockStyle.Top
        ' Add a toolbar, link it to the (already existing) commands:
        Dim tb As New C1ToolBar
        ' add file commands and the window menu to the toolbar
        tb.CommandLinks.Add(New C1CommandLink(cNew))
        tb.CommandLinks.Add(New C1CommandLink(cOpen))
        Dim cl As C1CommandLink
        cl = New C1CommandLink(mWindow)
        tb.CommandLinks.Add(cl)
        ' because we did not provide an image for the window menu,
        ' make it show as text
        cl.ButtonLook = ButtonLookFlags.Text
        cl = New C1CommandLink(cExit)
        tb.CommandLinks.Add(cl)
        ' ditto for the exit command
        cl.ButtonLook = ButtonLookFlags.Text
        ' add the new toolbar to the dock
        dock.Controls.Add(tb)

    End Sub

    Private Sub CommandClickHandler(ByVal sender As Object, ByVal e As CommandClickEventArgs)
        Dim cmdData As String = CType(e.Command.UserData, String)

        Select Case (cmdData)

            Case "file_new"
                Me.RichTextBox1.Text = String.Empty
                Me.Text = "New document"

            Case "file_open"
                Dim ofd As New OpenFileDialog
                ofd.Filter = "Text files|*.txt|Rich text files|*.rtf|All files|*.*"
                If (ofd.ShowDialog() = DialogResult.OK) Then

                    Select Case (ofd.FilterIndex)
                        Case 1
                            Me.RichTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText)
                        Case 2
                            Me.RichTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.RichText)
                        Case Else
                            Me.RichTextBox1.LoadFile(ofd.FileName)
                    End Select
                    Me.Text = ofd.FileName
                End If

            Case "exit"
                Dim f As Form
                For Each f In s_forms
                    f.Close()
                Next

            Case "window_new"
                Dim f1 As New Form1
                f1.Show()

            Case Else
                ' unknown command - should not happen
        End Select

    End Sub
这个是实例里的代码。我试了下就是上面截图的错误。
如果不使用上述代码,只是引用是不会报错的。
回复 使用道具 举报
chenfeng1029
金牌服务用户   /  发表于:2017-3-26 20:51:33
板凳
我检查了下手工添加工具栏和菜单按钮配置。看了下配置信息。
加入    CType(ch, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.C1CommandHolder1, System.ComponentModel.ISupportInitialize).EndInit()
就不会报错。
以后C1手工引用类,写代码添加时都必须使用上述进行初始化?
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-3-27 09:13:36
地板
谢谢您的反馈。
您直接拖控件到窗体,会自动生成相关的license信息。
如果在激活的情况下依然提示试用版信息,有可能是您的工程是在激活前创建。
您可以新建一个工程测试,拖拽控件,看是否依然有问题。

对于激活前创建的工程,在使用的时候,需要进行升级操作。
详细的步骤请参考产品博客:
http://blog.gcpowertools.com.cn/ ... ne_Activation2.aspx
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
chenfeng1029
金牌服务用户   /  发表于:2017-3-27 10:02:22
5#
你的意思是我如果引用这些C1的类,要使用这些控件拖拽下生成license后才可以?
这个不是很麻烦。
目前,我目前是下列方式直接写,后续是没报错。
CType(ch, System.ComponentModel.ISupportInitialize).BeginInit()
实现代码内容
        CType(Me.C1CommandHolder1, System.ComponentModel.ISupportInitialize).EndInit()
而且我也尝试过。我先拖拽,然后调用的实例,也是一样报相同的错误,只有使用上述2段代码后,才可以正常使用。
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-3-27 11:26:10
6#
chenfeng1029 发表于 2017-3-27 10:02
你的意思是我如果引用这些C1的类,要使用这些控件拖拽下生成license后才可以?
这个不是很麻烦。
目前, ...

默认这两句是VS自动生成的。
如果组件实现ISupportInitialize接口,那么设计器就会生成BeginInit和EndInit
http://msdn.microsoft.com/zh-cn/ ... lize(v=vs.110).aspx
如果是用C1ToolBar就是直接拖到窗体就可以使用。引用和license文件都是自动生成的。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部