Look at the following picture, which is showing a smart tag for DataGridView.
DataGridView Smart Tags http://img199.imageshack.us/img199/5871/post517531249536112.jpg
Now I'm creating a new component, and I want it to support showing some properties in smart tags. How do I add the properties to the smart tag?
You can also use Smart Tags in your Outlook e-mail messages and in Microsoft Excel. You can use Smart Tags to perform actions in Microsoft Word that you would normally start other programs to do. The purple dotted lines beneath text in your document indicate Smart Tags.
Click Tools > Options > Other. 3. In the Person Names section, click the Enable Person Names Smart Tag.
Last Updated on Wed, 06 Jan 2021. Visual Studio 2005 includes a new feature for creating a rich design-time experience—smart tags. Smart tags are the pop-up windows that appear next to a control when you click the tiny arrow in the corner. Smart tags are similar to menus in that they have a list of items.
Smart tags allow administrators to group emails and files together in folders. These can then be made available to users via the Mimecast Personal Portal or Mimecast for Outlook. Once users have access to smart tag messages, they can forward them to additional recipients, but they can't modify or delete them.
I used http://msdn.microsoft.com/en-us/library/default.aspx?q=smart+tag+windows+forms+designer.
As a result, I found Walkthrough: Adding Smart Tags to a Windows Forms Component.
Anyone who does the same search will find the same article.
Update: That link no longer works. I just tried a search for "smart tag windows forms designer", and found "Walkthrough: Adding Smart Tags to a Windows Forms Component" as the first search hit. The same search in Google shows "How to: Attach Smart Tags to a Windows Forms Component" as the first hit, but shows the same Walkthrough as the second hit.
You can use the following code to view a sample tag in a custom control.
And you can get a video about that from www.windowsclient.com.
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); }
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With