Я так понимаю, вы имеете в виду редактирование переменной через элемент управления PropertyGrid. если это так, вы можете вызвать пользовательский редактор свойств для редактирования этого конкретного объекта. Я также рекомендую переопределить функцию ToString, какой формат по вашему выбору. PropertyGrid использует это значение для отображения пользователю.
как реализовать собственный редактор:
public struct Vector2D : UITypeEditor
{
//UITypeEditor Implementation
//Gets the editor style, (dropdown, value or new window)
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
//Gets called when the value has to be edited.
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
//Calls a dialog to edit the object in
EditTypeConfig editor = new EditTypeConfig((TypeConfig)value);
editor.Text = context.PropertyDescriptor.Name;
if (editor.ShowDialog() == DialogResult.OK)
return editor.SelectedObject;
else
return (TypeConfig)value;
}
//Properties
[DisplayName("X"), Description("X is something"), Category("Value"), ReadOnly(false)]
public double X { get; set; }
[DisplayName("Y"), Description("Y is something"), Category("Value"), ReadOnly(false)]
public double Y { get; set; }
}
Использование:
public class Sample
{
[DisplayName("Value"), Description("Value is something"), Category("Vectors"), ReadOnly(false)]
[Editor(typeof(Vector2D), typeof(UITypeEditor))]
public Vector2D Value { get; set; }
//Editor(typeof(Vector2D)) calls a class that handles the the editing of that value
}
Я надеюсь, что это решит вашу проблему