How to implement IWindowsFormsEditorService in C# ? a.k.a Simulating In-Place Editing in Windows Forms
I would like 开发者_StackOverflow社区to implement a custom Windows-Forms based control similar to the Visual Studio property grid. For this, albeit much simpler. I would ideally like to replicate the behavior of the IWindowsFormsEditorService interface, that is used to trigger in-place editing in the property grid by calling client-specified UITypeEditor implementations.
As a simpler exemple, I only need to implement editing a value via a simulated ComboBox (or dropdown list) in a cell. The way Visual Studio does it does involve a real ComboBox control. Rather, Visual Studio displays a little dropdown button on the right of the cell which, when pressed, triggers the display and operations of a simple ListBox control, positioned in such a way as to simulate the ComboBox being dropped down.
I understand that for this to happen, I somehow need to implement my own modal message loop when editing is taking place. However, I have some trouble understanding how and where to put this message loop. I also have issues with the dropdown list expanding past the boundaries of my custom control.
I'm very proficient in COM and C++ but I would like to implement a pure C#-based solution for this.
What would be a good way to implement a simple simulated CombBox In-Place editing in a custom grid-like control?
You should make a separate form for the modal editing experience (containing a list box), then show it by calling ShowDialog()
.
The ShowDialog()
method will the modal message loop.
Since it's a separate form, you won't have any issues with the size of the parent control.
精彩评论