logo
down
shadow

How can I insert the EventsTab in the PropertyGrid?


How can I insert the EventsTab in the PropertyGrid?

By : user2954200
Date : November 22 2020, 01:01 AM
will be helpful for those in need If I understand correctly, you want to provide a way for the events for a Custom class to show in the VS IDE Property Editor.
This can be done fairly simply with only a few changes to your class. First, you need to understand that VS actually compiles your forms for use in the IDE designer. Specifically, all that designer code in InitializeComponent needs to be compiled in order to create/draw your form.
code :
class Validator:Component, ISupportInitialize
{
    // fake props
    public string Foo { get; set; }
    public int Bar  { get; set; }

    public event ValidatingEventHandler Validating;
    public delegate void ValidatingEventHandler(object sender, EventArgs e);

    public event ValidatedEventHandler Validated;
    public delegate void ValidatedEventHandler(object sender, EventArgs e);

    public Validator(string foo, int bar) 
    { 
    }
    public Validator()
    {
    }

    // ISupportInitialize methods
    public void BeginInit()
    { 
    }
    public void EndInit()
    {
    }
}
// 
// validator1
// 
this.validator1.Bar = 0;
this.validator1.Foo = null;
this.validator1.Validating += new Validator.ValidatingEventHandler(this.validator1_Validating);
...
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.validator1)).EndInit();
this.ResumeLayout(false);

...
private Validator validator1;          // note: no params
[Browsable(false)]
public string Foo { get; set; }
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int Bar  { get; set; }
Form.Validator.Items<ValidationItems>
[Serializable]
public class ValidationItem: Component
{
    [DefaultValue("")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public string DisplayName { get; set; }

    [DefaultValue(-1)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public int Value { get; set; }

    public event ValidatingEventHandler Validating;
    public delegate void ValidatingEventHandler(object sender, EventArgs e);

    public ValidationItem() 
    {
        Name = "New Item";
        Value = 0;
    }
}   
//  (Designer)
// validationItem1
// 
this.validationItem1.DisplayName = "New Item";
this.validationItem1.Value = 0;
this.validationItem1.Validating += new ValidationItem.ValidatingEventHandler(this.validationItem1_Validating);

...
private ValidationItem validationItem1;     // persistent form var
private void validationItem1_Validating(object sender, EventArgs e)
{

}
private void validationItem1_Validating(object sender, EventArgs e)
...
private void validationItem1_Validating_1(object sender, EventArgs e)
...
private void validationItem1_Validating_2(object sender, EventArgs e)
private void validator1_ValidationComplete(object sender, 
                     ValidationCompleteEventArgs e) 
{
}


Share : facebook icon twitter icon
wpf propertyGrid

wpf propertyGrid


By : user1540113
Date : March 29 2020, 07:55 AM
With these it helps This is due to a bug in the WPFPropertyGrid code.
It appears from his ThemeInfoAttribute that the author of that code intended to use a generic theme, but he mistakenly put his resources in the file "Themes/default.xaml" instead of "Themes/generic.xaml". Because of this the resources were not automatically loaded. He worked around the bug by loading the resources manually from his App.xaml.
code :
  <Application.Resources>

    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/WPGDemo;Component/Themes/Default.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

  </Application.Resources>
using PropertyGrid - Adding special property to PropertyGrid (e.x.: property that a user got a checkbox and a textbox)

using PropertyGrid - Adding special property to PropertyGrid (e.x.: property that a user got a checkbox and a textbox)


By : user2367986
Date : March 29 2020, 07:55 AM
this one helps. This type of information is spelled out in detail in Getting the Most Out of the .NET Framework PropertyGrid Control on MSDN.
WPF PropertyGrid Problem

WPF PropertyGrid Problem


By : sunlion
Date : March 29 2020, 07:55 AM
This might help you After hours of work i solved my problem. I had need only TypeConverter to solve this, so i created a class that derives from TypeConverter.
code :
    class PierListConverter : TypeConverter
        {
            ArrayList piers = new ArrayList();
            public PierListConverter()
            {

            }
            public override bool
            GetStandardValuesSupported(ITypeDescriptorContext context)
            {
                return true;
            }
            public override StandardValuesCollection
            GetStandardValues(ITypeDescriptorContext context)
            {
                // This method returns me the list that will use to fill combo at property grid.
                piers.Clear();
                foreach (var item in GullsEyeModel.GetInstance().GetPiers())
                {
                    piers.Add(item.Id);
                }
                StandardValuesCollection cols = new  StandardValuesCollection(piers);
                return cols;
            }
            public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
            {
               // If this method returns true, ConvertFrom method will invoke
                if (sourceType == typeof(string))
                {
                    return true;
                }
                else
                return base.CanConvertFrom(context, sourceType);
            }
            public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
            {
                // In this method i am getting selected text and querying; after that i retrieve proparete Guid value and then returning back to my object that binded property grid.
                if (value != null)
                {
                    if (value.ToString() == "Seçiniz")
                    {
                        return Guid.Empty;
                    }
                    else if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        GuidConverter g = new GuidConverter();
                        PierItem[] pierArray = GullsEyeModel.GetInstance().GetPiers();
                        PierItem selectedPier = pierArray.Where(item => item.Info.Name == value.ToString()).FirstOrDefault();
                        if (selectedPier != null)
                        {
                            return selectedPier.Id;
                        }
                        else
                            return base.ConvertFrom(context, culture, value);
                    }
                    else
                        return base.ConvertFrom(context, culture, value);
                }
                else
                return base.ConvertFrom(context, culture, value);
            }
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
            {
// In this method i am converting ID to string (Name) to display in Property Grid
                if (value != null)
                {
                    GuidConverter g = new GuidConverter();
                    PierItem[] piers = GullsEyeModel.GetInstance().GetPiers();
                    PierItem selectedPier = piers.Where(item => item.Id== (Guid)g.ConvertFromString(value.ToString())).FirstOrDefault();
                    if (selectedPier != null)
                    {
                        return selectedPier.Info.Name;
                    }
                    else
                        return "Seçiniz";
                }
                else
                return base.ConvertTo(context, culture, value, destinationType);
            }
        }
class MyClass
{

// my some props..

// my some props..

[TypeConverter(typeof(PierListConverter))]      
public Guid PierId {get; set;}

// my some methods..
}
PropertyGrid for Silverlight

PropertyGrid for Silverlight


By : user3518910
Date : March 29 2020, 07:55 AM
To fix the issue you can do There is a newest version of the same control and according to the documentation it is supporting Collections. You could find it in Silverlight 5 Property Grid
PropertyGrid - Property derived from IList<T>, How do I add to the PropertyGrid so user can Add/Edit/Remove items

PropertyGrid - Property derived from IList<T>, How do I add to the PropertyGrid so user can Add/Edit/Remove items


By : user3536801
Date : March 29 2020, 07:55 AM
Hope this helps The PropertyGrid is an old grumpy beast. It needs the non-generic IList explicit implementation, not the generic one.
As a site note, you could derive ZoneCollection directly from List, and you don't need any ICustomTypeDescriptor / PropertyDescriptor, with regards to this PropertyGrid issue.
code :
public class ZoneCollection : IList<Zone>, IList
{
    private List<Zone> _list = new List<Zone>();

    public ZoneCollection()
    {
    }

    public int IndexOf(Zone item)
    {
        return _list.IndexOf(item);
    }

    public void Insert(int index, Zone item)
    {
        _list.Insert(index, item);
    }

    public void RemoveAt(int index)
    {
        _list.RemoveAt(index);
    }

    public Zone this[int index]
    {
        get
        {
            return _list[index];
        }
        set
        {
            _list[index] = value;
        }
    }

    public void Add(Zone item)
    {
        _list.Add(item);
    }

    public void Clear()
    {
        _list.Clear();
    }

    public bool Contains(Zone item)
    {
        return _list.Contains(item);
    }

    public void CopyTo(Zone[] array, int arrayIndex)
    {
        _list.CopyTo(array, arrayIndex);
    }

    public int Count
    {
        get { return _list.Count; }
    }

    public bool IsReadOnly
    {
        get { return ((IList)_list).IsReadOnly; }
    }

    public bool Remove(Zone item)
    {
        return _list.Remove(item);
    }

    public IEnumerator<Zone> GetEnumerator()
    {
        return _list.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }

    int IList.Add(object value)
    {
        int index = Count;
        Add((Zone)value);
        return index;
    }

    bool IList.Contains(object value)
    {
        return Contains((Zone)value);
    }

    int IList.IndexOf(object value)
    {
        return IndexOf((Zone)value);
    }

    void IList.Insert(int index, object value)
    {
        Insert(index, (Zone)value);
    }

    bool IList.IsFixedSize
    {
        get { return ((IList)_list).IsFixedSize; }
    }

    bool IList.IsReadOnly
    {
        get { return ((IList)_list).IsReadOnly; }
    }

    void IList.Remove(object value)
    {
        Remove((Zone)value);
    }

    object IList.this[int index]
    {
        get
        {
            return this[index];
        }
        set
        {
            this[index] = (Zone)value;
        }
    }

    void ICollection.CopyTo(Array array, int index)
    {
        CopyTo((Zone[])array, index);
    }

    bool ICollection.IsSynchronized
    {
        get { return ((ICollection)_list).IsSynchronized; }
    }

    object ICollection.SyncRoot
    {
        get { return ((ICollection)_list).SyncRoot; }
    }
}
Related Posts Related Posts :
  • Stop Continuation Task upon exception thrown from parent task
  • Is there a way to make msbuild write error output to stderr?
  • Unit testing: TDD with POCO Objects with navigation properties (relationship fixup)
  • GridSplitter disables my RowDefinition style
  • Memory leak only in Release mode
  • how to read specified string from url
  • how to store html code EMail template in a string variable or textbox c#
  • Set Selected Date to TimePicker wpf (TimePickers inside DataTemplate)
  • How to draw line in Silverlight Specifying Height?
  • Stored procedure executes but does not update data
  • ASP.NET ListBox Trouble
  • Why does C# also not allow empty conditions in while loops?
  • Unable to get a block of code into my regex match groups
  • What is difference between dbcontext.Add and dbcontext.AddObject
  • How do I update the file version number of C# DLL without recompiling?
  • Value for html control always null
  • HttpClient hangs when timeout is setting (Windows Phone)
  • Handle Multiple Form tag in asp.net page?
  • create word document with html content in c#
  • Confusion about Find And Replace
  • Format sms messages in Clickatell
  • Automated Function Overload
  • String to date in MS Access SQL statement gives type mismatch error
  • ShowDialog exiting on certain events
  • Is there a try Convert.ToInt32... avoiding exceptions
  • How to move wpf application into minimize tray at Window Start-up C#?
  • How to change display format of long variable?
  • How to use Addfields in MongoDB C# Aggregation Pipeline
  • MsTest TestCleanup method not called when an unhandled exception is thrown
  • missing last data when exporting gridview to excel
  • How to add array of objects to List in c#
  • Lambda Expression to order (sort) my list collection
  • Library for displaying music notation
  • How to compare two dictionaries in c# and get the output as True and False after validation
  • specify fields to be serialized with JSON
  • How do you obtain the content of a specific node using XmlDocument in C#?
  • How to ignore the first line in a csv file when you read the csv file in C#
  • c# - Problem calling public void from class
  • How to tell a class which objects it should create? Type vs. object confusion :(
  • Save CheckBox state to xml
  • WIX CAQuietExec NETSH Command Fails
  • Issues sending http put request every 60 seconds to RoR app
  • ConfigurationManager.ConnectionStrings.ConnectionString Issue
  • Real size WPF controls for printing
  • How to cancel properly?
  • C# String multiplication error
  • Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs
  • Regex pattern for single backslash
  • TextBox: insert spaces for credit card number?
  • C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe
  • Debug a Windows Service with WCF library
  • Open a file from an external assembly?
  • Servicestack RegistrationFeature Unable to bind request
  • Index was outside the bounds of the array confusion
  • Error in Xml to List code. The ':' character, hexadecimal value 0x3A, cannot be included in a name
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org