Tree control with right-click menu (1)

xiaoxiao2021-03-14  180

User-defined control code is as follows:

Using system;

Using system.Web.ui;

Using system.Web.ui.webcontrols;

Using system.componentmodel;

Using system.io;

Namespace ewfs.cl

{

Public struct stutreenodes, PUBLIC STRUCTREENODES

{

Public String strkey;

Public String strdispval;

Public string strparentKey;

Public String strjavascriptcmd;

}

Public struct stutreenodesicons

{

PUBLIC STRING STRTREECAPTIONCIES

Public String StrtreeContentopenicon;

Public String StrtreeContentCloseicon;

}

Public struct stutreepopmenu

{

Public String strmenuitemimg;

Public String StrmenuItemText;

Public string strmenuitemcmd;

}

[DefaultProperty ("Text"),

ToolboxData ("<{0}: TreeView Runat = Server> ")]]

Public class treeview: system.web.ui.webcontrols.webcontrol

{

Private string m_treecaption; // Title

Private stutreenodes [] m_stutreenodes; // node content

Private stutreenodesicons m_stutreenodesicons; // node icon

Private string m_treechangedpostURL; // The address of the modified tree

Private bool m_treeadddir;

Private bool m_treeerendir;

Private bool m_treedeldir;

PRIVATETREEPOPMENU [] M_STUTREEPOPMENU

PRIVATE STRING M_GOTOID;

Private bool m_treerootpopmenu;

Private system.data.dataset m_dstreenodes;

protected system.web.ui.webcontrols.table treetable;

Public string treegotoid / / positioning ID

{

Get {return m_gotoid;}

Set {m_gotoid = value;}

}

[Bindable (TRUE),

Category ("APPEARANCE"),

DefaultValue (TRUE)]

Public Bool TreerootPopmenu

{

Get {return m_treerootpopmenu;

Set {m_treerootpopmenu = value;

}

[Bindable (TRUE),

Category ("APPEARANCE"),

DEFAULTVALUE ("")]

Public Bool Treeadddir

{

Get {return m_treeadddir;

Set {m_treeadddir = value;

}

Public Bool Treeerendir

{

Get {return m_treeerendir;}

Set {m_treeerendir = value;}}

Public Bool TreeDeldir

{

Get {return m_treedeldir;}

Set {m_treedeldir = value;

}

Public StutreePopmenu [] StutreePopmenu

{

Get {return m_stutreepopmenu;

Set {m_stutreepopmenu = value;

}

Public String TreechangedPostURL

{

Get {return m_treechangedposturl;}

Set {m_treechangedpostURL = value;

}

Public Stutreenodesicons Stutreenodesicons

{

Get {return m_stutreenodesicons;

Set {m_stutreenodesicons = value;

}

Public stutreenodes [] Stutreenodes

{

get

{

Return M_Stutreenodes;

}

set

{

M_Stutreenodes = VALUE;

}

}

Public String Treecaption

{

get

{

Return m_treecaption;

}

set

{

M_Treecaption = Value;

}

}

///

/// Get node content

///

Public system.data.dataset DStreenodes

{

Get {return this.m_dstreenodes;}

set

{

THIS.M_DSTREENODES = VALUE;

Settreenodes ();

}

}

Private void settreenodes ()

{

THIS.M_STUTREENODES = New stutreenodes [m_dstreenodes.tables [0] .rows.count];

For (int i = 0; i

{

THIS.M_STUTREENODES [I] .strkey = m_dstreenodes.tables [0] .ROWS [I] [0] .tostring ();

THIS.M_STUTREENODES [i] .strparentkey = m_dstreenodes.tables [0] .rows [i] [1] .tostring () == "0"? ": m_dstreenodes.tables [0] .rows [i] [1] .Tostring ();

This.m_stutreenodes [i] .strdispval = m_dstreenodes.tables [0] .rows [i] [2] .tostring ();

THIS.M_STUTREENODES [i] .strjavascriptcmd = m_dstreenodes.tables [0]. ROWS [I] [3] .tostring ();

}

}

///

/// Rendeze this control to the specified output parameter.

///

/// HTML writer to be written

Protected Override Void CreateChildControls ()

{

System.Web.ui.WebControls.table otb = new table ();

System.Web.ui.WebControls.table otb1 = new table (); system.Web.ui.WebControls.tableRow OTR = New TableRow ();

System.Web.ui.webcontrols.tablecell odd = new TableCell ();

System.Web.ui.WebControls.Unit ou = new unit ("98%");

System.Web.ui.ControlCollection OCC = NULL;

System.Web.ui.Control OC1 = NULL;

INT I;

/ / Output JS file

String scR = "; //"