In VB6, ToolTipText is a native property of controls. In .NET Windows Forms, tooltips are managed by a separate ToolTip component dragged onto the form. The standard VBUC migration often maps this to a helper method or ignores it. We will develop a feature to inject the specific ToolTip setup logic into the Form_Load event. 1. Analysis of the Source (VB6) VB6 Code Example:
// Inside the Form class private System.Windows.Forms.ToolTip ToolTip1; // Inside InitializeComponent or Form_Load this.ToolTip1 = new System.Windows.Forms.ToolTip(); this.ToolTip1.SetToolTip(this.Label1, "Click here to submit"); To develop this feature, we use the Artinsoft VBUC Extensibility API . This typically involves creating a class library in C# that the VBUC engine calls during the transformation phase.
public CodeExpression MapProperty(MemberMigrationContext context) { // 1. Identify the target control (the Label) var targetControl = context.SourceExpression; artinsoft+vbuc+v401042273+verified
Since the specific feature is not defined in your prompt, I will assume a scenario relevant to the migration process: (which does not exist on the standard .NET Label and usually requires a ToolTip component).
public bool AppliesTo(string vb6ControlName, string vb6PropertyName) { // Apply this logic only to Labels and the ToolTipText property return vb6ControlName.Equals("VB.Label", System.StringComparison.OrdinalIgnoreCase) && vb6PropertyName.Equals("ToolTipText", System.StringComparison.OrdinalIgnoreCase); } In VB6, ToolTipText is a native property of controls
using Artinsoft.VBUC.Extensions; using Artinsoft.VBUC.Helpers; using System.CodeDom; namespace CustomMigrations { public class CustomLabelMapper : IControlMapper { public string Name => "CustomLabelToolTipMapper";
CustomLabelMapper.cs
// 2. Access the parent form's components collection to add a ToolTip // We need a reference to a ToolTip object. // Ideally, the VBUC already added a ToolTip component to the form. // If not, we reference a helper or a global tool tip. // Strategy: Call a helper method that sets the tooltip. // This creates code like: Helper.SetToolTip(Label1, "Text"); var toolTipHelper = new CodeTypeReferenceExpression("MigrationHelpers.ToolTipHelper"); var value = context.ValueExpression;