PropertyGrid Usage (drop-down box)

xiaoxiao2021-03-06  15

If you have difficulties in the PropertyGrid, please refer to it. And hope that the master will make an opinion,

Note: The following code cannot be Run. This is a direct copy, my friends who want to use, need to repair some places.

using System; using System.Text; using System.Reflection; using System.Collections; using System.ComponentModel; using System.Runtime.InteropServices; using System.Data; using System.Drawing; using System.Drawing.Design;

namespace Com.WorkFlowEnginer.Entity {#region down list control objects built [Role] // object selection drop-down list conversion public class DropDownListRoleConverter: System.Drawing.Design.UITypeEditor {public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context) {return System.Drawing. Design.uitypeEditorEditStyle.dropdown;}

public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value) {System.Windows.Forms.Design.IWindowsFormsEditorService iws = (System.Windows.Forms.Design.IWindowsFormsEditorService) provider.GetService (typeof (System.Windows.Forms.Design ! .IWindowsFormsEditorService)); if (iws = null) {DropDownListRoleControll dlc = new DropDownListRoleControll (iws); iws.DropDownControl (dlc); return dlc.SelectString;} return value;}} public class DropDownListRoleControll: System.Windows.Forms. ListBox {public DropdownListrolecontrol (System.Windows.Forms.Design.iWindowsformSeditorService IWS) {// Initialization drop-down list Requirements

DataTable DT = com.workflownginer.Rolemanager.getroleList (); if (dt! = Null& Dt.Rows.count> 0) {Role Role = new role (); role.rolegUID = DR ["guid"]. TOSTRING (); role.name = DR ["name"]. Tostring (); this.items.add (role);}} this._iws = IWS; this.visible = true; THISHEIGHT = 100; this.borderstyle = system.windows.Forms.Borderstyle.none; // Add event this.selectedValueChanged = New EventHandler (CB_SelectedValueChanged);} // can be modified here

private Com.WorkFlowEnginer.Entity.Role select = null; public Com.WorkFlowEnginer.Entity.Role SelectString {get {return this.select;}} private System.Windows.Forms.Design.IWindowsFormsEditorService _iws;

Private Void CB_SelectedValueChanged (Object Sender, Eventargs E) {if (this.selectedItem! = null) {

// Require this.Select = (com.workflowenginer.Entity.Role) this.Role, this.Role, this is required here, this._iws.closedropdown ();} else system.windows.Forms.MessageBox.show ("No object", "Tips", System.Windows.forms.MessageBoxButtons.ok, System.Windows.Forms.MessageBoxicon.Error;}} #ENDREGION

Public Class Activity

{

[Name ( "process required for the role of CategoryAttribute (" Activity Properties "), ReadOnlyAttribute (false), BrowsableAttribute (true), EditorAttribute (typeof (DropDownListRoleConverter), typeof (System.Drawing.Design.UITypeEditor)), DescriptionAttribute. "), ShowCHINESE (" Role Name: ")]

// Require Public Role Role {Get {RETURN ROLE;} Set {Role = Value;}}

}

转载请注明原文地址:https://www.9cbs.com/read-48045.html

New Post(0)