English 中文(简体)
如何在2010年演播室制作新的内容
原标题:How to create new components in Visual Studio 2010

Can you tell me how to create new visual component for .net 4.0 in Visual Studio 2010, i have a book about component creation in Russian Language (Pavel Agurov -Razrabotka Komponentov v MS Visual Studio 2005/2008), but methods in this book covers VS 2005 and 2008. And methods gives some errors in VS 2010.

EDIT: There is my code

public partial class exComboBox : ComboBox
{
    /*public exComboBox()
    {
        InitializeComponent();
    }*/
    private System.Collections.Specialized.StringCollection _itemValues = new System.Collections.Specialized.StringCollection();

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [Editor("System.Windows.Forms.Design.StringCollectionEditor,System.Editor","System.Drawing.Design.UITypeEditor,System.Drawing")]
    public System.Collections.Specialized.StringCollection ItemValues
    {
        get
        {
            return _itemValues;
        }
        set
        {
            _itemValues = value;
        }
    }
    public object SelectedItemValue
    {
        get
        {
            return _itemValues[SelectedIndex];
        }
    }
}

And when I try to add this component to new form and add values for ItemValues it says
Constructor on type System.String not found.

问题回答

右边点击你的项目,选择增加一个新项目。 进入C#节,选择用户控制。

这将产生一种窗口控制,在你使用表格设计器时,这种控制将出现在工具箱顶上。 仅仅拖拉,把它像任何其他控制一样,变成你。

如果你想从Combo Box中获取,那么就把创建的那类产品从用户Control改成 com子。 你们也许还需要改变主线,改用3个基级建筑商,而不是自己做初步的委员会。

If you want to use this control in many applications, then you can put the code into a Class Library project, which will make a .dll assembly that other projects can reference to gain access to the control.

创建Windows Application,然后通过右边点点击解决方案探索者的项目,再添加新项目菜单,然后可以看见AFAIR。

假设你重新谈论Winforms......

依靠现有控制可能不是你想要做的事。 尤其是如果你想要改变其违约行为或取代其现有财产的话。 不久或之后,你将面临严重限制。 相信我,我就在那里。

If you want an easy way to repeat some kind of pattern for a ComboBox, I suggest you take a look at IExtenderProvider interface. You can implement it on a Component-derived class that you can drag on the design surface. In this component, you can declare properties that will be attached as extra properties to any comboboxes (or anything else, it s all up to you).

由于该构成部分将了解该构成部分的任何附属内容,因此,它将能够申报活动处理者对所附控制/构成部分的影响。 例如,如果你希望您的 com贝箱有已经存在的物品,你可以处理<代码>Load的活动,并添加其中的项目。

To learn more about IExtenderProvider, go here.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签