protected void AddHelpSupport(Control control, object actualModel, string propertyName, int offset) { var properties = TypeDescriptor.GetProperties(actualModel); var attributes = properties[propertyName].Attributes; var helpStringAttribute = (HelpStringAttribute)attributes[typeof(HelpStringAttribute)]; if (helpStringAttribute == null) { return; } var content = helpStringAttribute.Content; if (!string.IsNullOrEmpty(helpStringAttribute.HelpResourceKey)) { content = HelpResources.ResourceManager.GetString(helpStringAttribute.HelpResourceKey); } if (string.IsNullOrEmpty(content)) { return; } helpProvider.SetHelpString(control, content); helpProvider.SetShowHelp(control, true); var helpButton = new HelpButton(control, helpProvider); helpButton.Location = CalculateHelpButtonLocation(control, helpButton, offset); control.Parent.Controls.Add(helpButton); control.Parent.Controls.SetChildIndex(helpButton, control.Parent.Controls.IndexOf(control) + 1); helpButton.TabIndex = control.TabIndex + 1; }
protected void AddHelpSupport(Control control, object actualModel, string propertyName, int offset) { var properties = TypeDescriptor.GetProperties(actualModel); var attributes = properties[propertyName].Attributes; var helpStringAttribute = (HelpStringAttribute) attributes[typeof(HelpStringAttribute)]; if(helpStringAttribute == null) { return; } var content = helpStringAttribute.Content; if(!string.IsNullOrEmpty(helpStringAttribute.HelpResourceKey)) { content = HelpResources.ResourceManager.GetString(helpStringAttribute.HelpResourceKey); } if(string.IsNullOrEmpty(content)) { return; } helpProvider.SetHelpString(control, content); helpProvider.SetShowHelp(control, true); var helpButton = new HelpButton(control, helpProvider); helpButton.Location = CalculateHelpButtonLocation(control, helpButton, offset); control.Parent.Controls.Add(helpButton); control.Parent.Controls.SetChildIndex(helpButton, control.Parent.Controls.IndexOf(control) + 1); helpButton.TabIndex = control.TabIndex + 1; }