<tfoot id='nTSKu'></tfoot>

    <i id='nTSKu'><tr id='nTSKu'><dt id='nTSKu'><q id='nTSKu'><span id='nTSKu'><b id='nTSKu'><form id='nTSKu'><ins id='nTSKu'></ins><ul id='nTSKu'></ul><sub id='nTSKu'></sub></form><legend id='nTSKu'></legend><bdo id='nTSKu'><pre id='nTSKu'><center id='nTSKu'></center></pre></bdo></b><th id='nTSKu'></th></span></q></dt></tr></i><div id='nTSKu'><tfoot id='nTSKu'></tfoot><dl id='nTSKu'><fieldset id='nTSKu'></fieldset></dl></div>

    1. <small id='nTSKu'></small><noframes id='nTSKu'>

        <bdo id='nTSKu'></bdo><ul id='nTSKu'></ul>
      <legend id='nTSKu'><style id='nTSKu'><dir id='nTSKu'><q id='nTSKu'></q></dir></style></legend>
      1. 如何强制 PropertyGrid 显示特定属性的自定义对话框?

        时间:2023-07-28
            • <i id='EX4FR'><tr id='EX4FR'><dt id='EX4FR'><q id='EX4FR'><span id='EX4FR'><b id='EX4FR'><form id='EX4FR'><ins id='EX4FR'></ins><ul id='EX4FR'></ul><sub id='EX4FR'></sub></form><legend id='EX4FR'></legend><bdo id='EX4FR'><pre id='EX4FR'><center id='EX4FR'></center></pre></bdo></b><th id='EX4FR'></th></span></q></dt></tr></i><div id='EX4FR'><tfoot id='EX4FR'></tfoot><dl id='EX4FR'><fieldset id='EX4FR'></fieldset></dl></div>

                <legend id='EX4FR'><style id='EX4FR'><dir id='EX4FR'><q id='EX4FR'></q></dir></style></legend>
                  <bdo id='EX4FR'></bdo><ul id='EX4FR'></ul>
                    <tbody id='EX4FR'></tbody>

                  <tfoot id='EX4FR'></tfoot>

                • <small id='EX4FR'></small><noframes id='EX4FR'>

                  本文介绍了如何强制 PropertyGrid 显示特定属性的自定义对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有字符串属性的类,它同时具有 getter 和 setter,通常太长以至于 PropertyGrid 会截断字符串值.如何强制 PropertyGrid 显示省略号,然后启动包含多行文本框的对话框,以便轻松编辑属性?我知道我可能必须在属性上设置某种属性,但是什么属性以及如何设置?我的对话框是否必须实现一些特殊的设计器界面?

                  I have a class with a string property, having both a getter and a setter, that is often so long that the PropertyGrid truncates the string value. How can I force the PropertyGrid to show an ellipsis and then launch a dialog that contains a multiline textbox for easy editing of the property? I know I probably have to set some kind of attribute on the property, but what attribute and how? Does my dialog have to implement some special designer interface?

                  更新:这 可能是我的问题的答案,但我找不到它搜索.我的问题比较笼统,它的答案可以用来构建任何类型的自定义编辑器.

                  Update: This is probably the answer to my question, but I could not find it by searching. My question is more general, and its answer can be used to build any type of custom editor.

                  推荐答案

                  你需要为属性设置一个[Editor(...)],给它一个UITypeEditor;像这样(使用您自己的编辑器...)

                  You need to set an for the property, giving it a UITypeEditor that does the edit; like so (with your own editor...)

                  using System;
                  using System.ComponentModel;
                  using System.Drawing.Design;
                  using System.Windows.Forms;
                  using System.Windows.Forms.Design;
                  
                  
                  static class Program
                  {
                      static void Main()
                      {
                          Application.Run(new Form { Controls = { new PropertyGrid { SelectedObject = new Foo() } } });
                      }
                  }
                  
                  
                  
                  class Foo
                  {
                      [Editor(typeof(StringEditor), typeof(UITypeEditor))]
                      public string Bar { get; set; }
                  }
                  
                  class StringEditor : UITypeEditor
                  {
                      public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
                      {
                          return UITypeEditorEditStyle.Modal;
                      }
                      public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
                      {
                          IWindowsFormsEditorService svc = (IWindowsFormsEditorService)
                              provider.GetService(typeof(IWindowsFormsEditorService));
                          if (svc != null)
                          {
                              svc.ShowDialog(new Form());
                              // update etc
                          }
                          return value;
                      }
                  }
                  

                  您可能会通过查看行为符合您需要的现有属性来追踪现有编辑器.

                  You might be ablt to track down an existing Editor by looking at existing properties that behave like you want.

                  这篇关于如何强制 PropertyGrid 显示特定属性的自定义对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      • <legend id='VeFJi'><style id='VeFJi'><dir id='VeFJi'><q id='VeFJi'></q></dir></style></legend>
                        • <bdo id='VeFJi'></bdo><ul id='VeFJi'></ul>
                          <i id='VeFJi'><tr id='VeFJi'><dt id='VeFJi'><q id='VeFJi'><span id='VeFJi'><b id='VeFJi'><form id='VeFJi'><ins id='VeFJi'></ins><ul id='VeFJi'></ul><sub id='VeFJi'></sub></form><legend id='VeFJi'></legend><bdo id='VeFJi'><pre id='VeFJi'><center id='VeFJi'></center></pre></bdo></b><th id='VeFJi'></th></span></q></dt></tr></i><div id='VeFJi'><tfoot id='VeFJi'></tfoot><dl id='VeFJi'><fieldset id='VeFJi'></fieldset></dl></div>

                          <tfoot id='VeFJi'></tfoot>

                          <small id='VeFJi'></small><noframes id='VeFJi'>

                            <tbody id='VeFJi'></tbody>