如何将智能标签添加到我的.NET组件?

问题描述 投票:0回答:2
看以下图片,该图片显示了DataGridView的智能标签。

datagridView智能标签http://img199.imageshack.us/img199/5871/post517531249536112.jpgg

现在我正在创建一个新组件,我希望它支持在智能标签中显示一些属性。如何将属性添加到智能标签?

c# .net vb.net visual-studio components
2个回答
5
投票
Http://msdn.microsoft.com/en-us/library/default.aspx?q = smart+tag+tag+windows+windows+fornes+forms+designer

. 结果,我找到了

walkthrough:将智能标签添加到Windows表单组件

.。 lony进行相同搜索的任何人都会找到同一篇文章。

update:该链接不再有效。我只是尝试搜索

“智能标签Windows forms Designer”


,并找到了“

”演练:在第一次搜索hit中添加智能标签。在google中相同的搜索显示“如何:将智能标签附加到Windows表单组件”作为第一个命中,但显示与第二次命中相同的演练。 您可以使用以下代码在自定义控件中查看示例标签。 您可以从www.windowsclient.com.

获得有关该视频的视频。

3
投票
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using System.ComponentModel.Design; namespace MakeSmartTag { public enum Languages { English, Arabic, Japanese } [Designer(typeof(UserControlDesigner))] public partial class UserControl2 : UserControl { public UserControl2() { InitializeComponent(); } private Languages _language; public Languages Language { get { return _language; } set { switch (value) { case Languages.Arabic: { label1.Text = "مرحباً"; _language = value; } break; case Languages.English: { label1.Text = "Hello"; _language = value; } break; case Languages.Japanese: { label1.Text = "Conechoa"; _language = value; } break; } } } } public class UserControlDesigner : System.Windows.Forms.Design.ControlDesigner { private DesignerActionListCollection lists; public override DesignerActionListCollection ActionLists { get { if (lists == null) { lists = new DesignerActionListCollection(); lists.Add(new UserControlActioonList(this.Component)); } return lists; } } } public class UserControlActioonList : DesignerActionList { private UserControl2 myUserControl; private DesignerActionUIService designerActionSvc = null; public UserControlActioonList(IComponent component) : base(component) { this.myUserControl = (UserControl2)component; this.designerActionSvc = (DesignerActionUIService)GetService(typeof(DesignerActionUIService)); } private PropertyDescriptor GetPropertyByName(string propName) { PropertyDescriptor prop = default(PropertyDescriptor); prop = TypeDescriptor.GetProperties(myUserControl)[propName]; if (prop == null) { throw new ArgumentException("Invalid Property", propName); } else { return prop; } } public override System.ComponentModel.Design.DesignerActionItemCollection GetSortedActionItems() { DesignerActionItemCollection item = new DesignerActionItemCollection(); item.Add(new DesignerActionHeaderItem( "المظهر")); item.Add(new DesignerActionPropertyItem( "BackColor", "لون الخلفية", "Appearance", "Set background Color of the control")); item.Add(new DesignerActionHeaderItem("تحديد اللغة")); item.Add(new DesignerActionPropertyItem( "Language", "اللغة", "Functions", "Set the language of the control")); return item; } public Color BackColor { get { return this.myUserControl.BackColor; } set { GetPropertyByName("BackColor").SetValue(myUserControl, value); } } public Languages Language { get { return this.myUserControl.Language; } set { GetPropertyByName("Language").SetValue(myUserControl, value); } } } }

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.