locked
Ribbon Control

    Question

  • Hi,

    I found a Ribbon Control on Codeproject, which i wanted to add to my project, but I keep getting an error.

    Project: Ribbon Control
    Error: The Typ "System.Windows.Forms.Ribbon" is not defined (translated)

    My Form.Designer is auto-generated (one Ribbon Control added on my form):

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class MainForm
        Inherits System.Windows.Forms.Form
    
        'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
        <System.Diagnostics.DebuggerNonUserCode()> _
        Protected Overrides Sub Dispose(ByVal disposing As Boolean)
            Try
                If disposing AndAlso components IsNot Nothing Then
                    components.Dispose()
                End If
            Finally
                MyBase.Dispose(disposing)
            End Try
        End Sub
    
        'Wird vom Windows Form-Designer benötigt.
        Private components As System.ComponentModel.IContainer
    
        'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
        'Das Bearbeiten ist mit dem Windows Form-Designer möglich.  
        'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()
            Me.Ribbon1 = New System.Windows.Forms.Ribbon()
            Me.SuspendLayout()
            '
            'Ribbon1
            '
            Me.Ribbon1.Font = New System.Drawing.Font("Segoe UI", 9.0!)
            Me.Ribbon1.Location = New System.Drawing.Point(0, 0)
            Me.Ribbon1.Minimized = False
            Me.Ribbon1.Name = "Ribbon1"
            '
            '
            '
            Me.Ribbon1.OrbDropDown.BorderRoundness = 8
            Me.Ribbon1.OrbDropDown.Location = New System.Drawing.Point(0, 0)
            Me.Ribbon1.OrbDropDown.Name = ""
            Me.Ribbon1.OrbDropDown.Size = New System.Drawing.Size(527, 447)
            Me.Ribbon1.OrbDropDown.TabIndex = 0
            Me.Ribbon1.OrbImage = Nothing
            '
            '
            '
            Me.Ribbon1.QuickAcessToolbar.AltKey = Nothing
            Me.Ribbon1.QuickAcessToolbar.Image = Nothing
            Me.Ribbon1.QuickAcessToolbar.Tag = Nothing
            Me.Ribbon1.QuickAcessToolbar.Text = Nothing
            Me.Ribbon1.QuickAcessToolbar.ToolTip = Nothing
            Me.Ribbon1.QuickAcessToolbar.ToolTipImage = Nothing
            Me.Ribbon1.QuickAcessToolbar.ToolTipTitle = Nothing
            Me.Ribbon1.Size = New System.Drawing.Size(284, 138)
            Me.Ribbon1.TabIndex = 0
            Me.Ribbon1.TabSpacing = 6
            Me.Ribbon1.Text = "Ribbon1"
            '
            'MainForm
            '
            Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
            Me.ClientSize = New System.Drawing.Size(284, 262)
            Me.Controls.Add(Me.Ribbon1)
            Me.Name = "MainForm"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
        Friend WithEvents Ribbon1 As System.Windows.Forms.Ribbon
    
    End Class

    If you need more information then let my know.

    Thank's in advance.

    Joda-oda



    • Edited by Joda-oda Tuesday, April 17, 2012 10:57 AM
    Tuesday, April 17, 2012 10:56 AM

Answers

  • Ok,

    i could solve the issue:

    Change the source ( both projects ) so they are targetting Net 3.5 framework and compile

    Change your project also to NET 3.5 framework.

    I have no idea why there is a problem if the winform project ( where you use the Ribbon ) is targetting NET 4.0, but it just works with NET 3.5.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Joda-oda Wednesday, April 18, 2012 9:29 AM
    Wednesday, April 18, 2012 7:26 AM
  • Ok,

    i have another update for you ;-)

    You can keep alomst anything like it had been ( if your Winform Project is targetting NET 4.0, not the client profile ).

    You need to change one line of code in the Ribbon Source:

    // replace this
    _hHook = WinApi.SetWindowsHookEx(htype, _HookProc, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
    // with this
    _hHook = WinApi.SetWindowsHookEx(htype, _HookProc, IntPtr.Zero, 0);

    This line is inside the GlobalHook.cs file ( namespace System.Windows.Forms.RibbonHelpers ) inside the private void InstallHook() method.

    Solution found here:http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/9bb5e76d-e9a3-4264-a9e9-842e6ff5ac32 ( lastr post from user noorbakhsh )


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Joda-oda Wednesday, April 18, 2012 9:29 AM
    Wednesday, April 18, 2012 7:36 AM

All replies

  • Hi,

    check out this tutorial for the usage of the ribbon: http://www.codeproject.com/Articles/364272/Easily-Add-a-Ribbon-Into-a-WinForms-Application-Cs

    Yes, i know it is targeting C# but i guess your problem is with the reference.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/


    • Edited by Heslacher Tuesday, April 17, 2012 11:01 AM
    Tuesday, April 17, 2012 11:00 AM
  • Hi,

    I also know this article, but I still can't manage it to work.

    Joda-oda

    Tuesday, April 17, 2012 11:42 AM
  • Did you add a reference to the ribbon control ?

    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, April 17, 2012 11:43 AM
  • You wrote "(one Ribbon Control added on my form)". So have already added the control using the designer? After adding it, you get the error? Strange.

    Did you create your own namespace called "System" in your project?


    Armin

    Tuesday, April 17, 2012 11:46 AM
  • @ Hannes, yes i added the refrence.
    @ Amrin, ich added one Ribbon Control via drag an drop, the Form.Designer code was auto-generated

    Maybe, s.o. could upload a sample project?
    Tuesday, April 17, 2012 12:06 PM
  • I just did the same ( for sure after compiling the Ribbon ) using VB 2008 without any problems.

    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/


    • Edited by Heslacher Tuesday, April 17, 2012 12:14 PM
    Tuesday, April 17, 2012 12:14 PM
  • Did you create your own namespace called "System" in your project?

    Armin

    Tuesday, April 17, 2012 12:34 PM
  • Armin,

    the original author of this control did so.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, April 17, 2012 12:36 PM
  • the original author of this control did so.

    I'm not sure what you mean...   The problem is that if you create your own namespace "System" in your project, "System" in "System.Windows.Forms.Ribbon" refers to that namespace instead of Global.System.Windows.Forms.Ribbon. As we can't make the designer add "Global" in front, we should avoid naming a namespace "System".

    EDIT: However, as other references to System don't fail, this probably doesn't apply, so I also have no other explanation.


    Armin


    Tuesday, April 17, 2012 1:05 PM
  • @ Hannes: Can you post your working code?
    • Edited by Joda-oda Tuesday, April 17, 2012 1:08 PM
    Tuesday, April 17, 2012 1:07 PM
  • I have downloaded this control and checked the source. The author of the ribbon control did add the System.Windows.Forms namespace for the class.

    namespace System.Windows.Forms
    {
        /// <summary>
        /// Provides a Ribbon toolbar
        /// </summary>
        [Designer(typeof(RibbonDesigner))]
        public class Ribbon
            : Control
        {.........


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, April 17, 2012 1:08 PM
  • I have downloaded this control and checked the source. The author of the ribbon control did add the System.Windows.Forms namespace for the class.

    The problem is that if you create your own namespace "System" in your project, "System" in "System.Windows.Forms.Ribbon" refers to that namespace instead of Global.System.Windows.Forms.Ribbon. As we can't make the designer add "Global" in front, we should avoid naming a namespace "System".

    Armin

    Tuesday, April 17, 2012 1:41 PM
  • It is just the source i have downloaded today.

    I compiled the System.Windows.Forms.Ribbon project ( release mode ) and in a new win form project added the control to the toolbox.

    I didn`t change anything.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, April 17, 2012 1:47 PM
  • I did what you mentioned but it still doesn't run.
    I'm sorry but I forgot to mention that I use Visual Studio 2010.
    The author of the article mentioned, that this might cause problems, but I also followed that
    specific instruction and I still can't compile it.

    Maybe s.o. with Visual Studio (Basic) 2010 could try it.
    Tuesday, April 17, 2012 2:33 PM
  • Hi again,

    i opened the project with VS 2010 and converted the project. Now it doesn`t run either. I have figured out the problem inside the InstallHook() method of the RibbonHelpers.GlobalHook class.

    If i have the time i will investigate further tomorrow.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Tuesday, April 17, 2012 3:10 PM
  • Thank you.
    Tuesday, April 17, 2012 3:21 PM
  • Ok,

    i could solve the issue:

    Change the source ( both projects ) so they are targetting Net 3.5 framework and compile

    Change your project also to NET 3.5 framework.

    I have no idea why there is a problem if the winform project ( where you use the Ribbon ) is targetting NET 4.0, but it just works with NET 3.5.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Joda-oda Wednesday, April 18, 2012 9:29 AM
    Wednesday, April 18, 2012 7:26 AM
  • Ok,

    i have another update for you ;-)

    You can keep alomst anything like it had been ( if your Winform Project is targetting NET 4.0, not the client profile ).

    You need to change one line of code in the Ribbon Source:

    // replace this
    _hHook = WinApi.SetWindowsHookEx(htype, _HookProc, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
    // with this
    _hHook = WinApi.SetWindowsHookEx(htype, _HookProc, IntPtr.Zero, 0);

    This line is inside the GlobalHook.cs file ( namespace System.Windows.Forms.RibbonHelpers ) inside the private void InstallHook() method.

    Solution found here:http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/9bb5e76d-e9a3-4264-a9e9-842e6ff5ac32 ( lastr post from user noorbakhsh )


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    • Marked as answer by Joda-oda Wednesday, April 18, 2012 9:29 AM
    Wednesday, April 18, 2012 7:36 AM
  • It works - Thank you verry much!
    Wednesday, April 18, 2012 9:30 AM