1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コレクションエディタのメンバペインの表示名変更

Posted at

コレクションエディタのメンバー名は規定ではコレクション要素のクラス名が表示されます。これを任意文字列に変更するサンプルです。

(元の表示)
CollectionEditor00.png

code

/// <summary>
/// プロパティグリッドでプロパティを設定するクラス
/// </summary>
public class PropertyGridSample
{
    public List<Sample> Samples { get; set; }
}

/// <summary>
/// コレクションエディタで設定するプロパティ
/// </summary>
public class Sample
{
    public string Content { get; set; }
}

(プロパティに設定した文字列を使用)
CollectionEditor01.png

code

/// <summary>
/// コレクションエディタで設定するプロパティ
/// </summary>
public class Sample
{
    public string Content { get; set; }

    /// <summary>
    /// メンバーに表示する文字列を返す
    /// </summary>
    /// <returns></returns>
    public override string ToString()
    {
        if (string.IsNullOrEmpty(Content))
        {
            return "Sample";
        }
        return Content;
    }
}
1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?