|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
UN AUTRE TREEVIEW
Information sur la source
Description
Ce treeview possède en plus des fonctionnalités standards du treeview, - la possibilité d'afficher des colonnes en plus de la colonne "Arbre" - la possibilité de surligner un "chemin" depuis la racine de l'arbre vers un ou plusieurs noeuds - la possibilité d'afficher/cacher un "header" - de trier par colonne dans le mode affichage en grille
Source
- Exemple d'utilisation
-
- using System;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.Windows.Forms;
-
- namespace Genius.Controls
- {
- /// <summary>
- /// Summary description for DemoTreeView.
- /// </summary>
- public class DemoTreeView : Form
- {
- private GeniusTreeView FTree;
-
- private Panel panel1;
- private Splitter splitter1;
- private Panel pnlTreeview;
- private CheckBox cbShowHeader;
- private CheckBox cbShowTreeLines;
- private CheckBox cbuseColumns;
- private ContextMenu contextMenu1;
- private MenuItem menuItem10;
- private MenuItem menuItem11;
- private MenuItem menuItem12;
- private MenuItem menuItem13;
- private MenuItem menuItem14;
- private MenuItem menuItem15;
- private MenuItem menuItem16;
- private MenuItem menuItem17;
- private MenuItem menuItem18;
- private MenuItem menuItem19;
- private MenuItem menuItem20;
- private CheckBox cbCanEdit;
- private CheckBox cbCanCheck;
- private CheckBox cbCanUncheck;
- private CheckBox checkBox4;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.CheckBox cbHGridLine;
- private System.Windows.Forms.CheckBox cbVGridLine;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private Container components = null;
-
- public DemoTreeView()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
-
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- }
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
-
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.panel1 = new System.Windows.Forms.Panel();
- this.cbVGridLine = new System.Windows.Forms.CheckBox();
- this.label1 = new System.Windows.Forms.Label();
- this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.cbCanUncheck = new System.Windows.Forms.CheckBox();
- this.cbCanCheck = new System.Windows.Forms.CheckBox();
- this.cbCanEdit = new System.Windows.Forms.CheckBox();
- this.cbuseColumns = new System.Windows.Forms.CheckBox();
- this.cbHGridLine = new System.Windows.Forms.CheckBox();
- this.cbShowTreeLines = new System.Windows.Forms.CheckBox();
- this.cbShowHeader = new System.Windows.Forms.CheckBox();
- this.splitter1 = new System.Windows.Forms.Splitter();
- this.pnlTreeview = new System.Windows.Forms.Panel();
- this.contextMenu1 = new System.Windows.Forms.ContextMenu();
- this.menuItem10 = new System.Windows.Forms.MenuItem();
- this.menuItem20 = new System.Windows.Forms.MenuItem();
- this.menuItem11 = new System.Windows.Forms.MenuItem();
- this.menuItem12 = new System.Windows.Forms.MenuItem();
- this.menuItem13 = new System.Windows.Forms.MenuItem();
- this.menuItem14 = new System.Windows.Forms.MenuItem();
- this.menuItem15 = new System.Windows.Forms.MenuItem();
- this.menuItem16 = new System.Windows.Forms.MenuItem();
- this.menuItem17 = new System.Windows.Forms.MenuItem();
- this.menuItem18 = new System.Windows.Forms.MenuItem();
- this.menuItem19 = new System.Windows.Forms.MenuItem();
- this.panel1.SuspendLayout();
- this.SuspendLayout();
- //
- // panel1
- //
- this.panel1.Controls.Add(this.cbVGridLine);
- this.panel1.Controls.Add(this.label1);
- this.panel1.Controls.Add(this.checkBox4);
- this.panel1.Controls.Add(this.cbCanUncheck);
- this.panel1.Controls.Add(this.cbCanCheck);
- this.panel1.Controls.Add(this.cbCanEdit);
- this.panel1.Controls.Add(this.cbuseColumns);
- this.panel1.Controls.Add(this.cbHGridLine);
- this.panel1.Controls.Add(this.cbShowTreeLines);
- this.panel1.Controls.Add(this.cbShowHeader);
- this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
- this.panel1.Location = new System.Drawing.Point(0, 0);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(520, 72);
- this.panel1.TabIndex = 0;
- //
- // cbVGridLine
- //
- this.cbVGridLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbVGridLine.Location = new System.Drawing.Point(16, 56);
- this.cbVGridLine.Name = "cbVGridLine";
- this.cbVGridLine.Size = new System.Drawing.Size(103, 16);
- this.cbVGridLine.TabIndex = 9;
- this.cbVGridLine.Text = "ShowGridlines ?";
- this.cbVGridLine.CheckedChanged += new System.EventHandler(this.cbVGridLine_CheckedChanged);
- //
- // label1
- //
- this.label1.AllowDrop = true;
- this.label1.Location = new System.Drawing.Point(392, 24);
- this.label1.Name = "label1";
- this.label1.TabIndex = 8;
- this.label1.Text = "Drag or Drop";
- this.label1.GiveFeedback += new System.Windows.Forms.GiveFeedbackEventHandler(this.label1_GiveFeedback);
- this.label1.DragEnter += new System.Windows.Forms.DragEventHandler(this.label1_DragEnter);
- this.label1.DragOver += new System.Windows.Forms.DragEventHandler(this.label1_DragOver);
- this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);
- //
- // checkBox4
- //
- this.checkBox4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.checkBox4.Location = new System.Drawing.Point(216, 8);
- this.checkBox4.Name = "checkBox4";
- this.checkBox4.Size = new System.Drawing.Size(104, 16);
- this.checkBox4.TabIndex = 7;
- this.checkBox4.Text = "usecolumns ?";
- //
- // cbCanUncheck
- //
- this.cbCanUncheck.Checked = true;
- this.cbCanUncheck.CheckState = System.Windows.Forms.CheckState.Checked;
- this.cbCanUncheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbCanUncheck.Location = new System.Drawing.Point(216, 48);
- this.cbCanUncheck.Name = "cbCanUncheck";
- this.cbCanUncheck.Size = new System.Drawing.Size(104, 16);
- this.cbCanUncheck.TabIndex = 6;
- this.cbCanUncheck.Text = "CanUncheck";
- //
- // cbCanCheck
- //
- this.cbCanCheck.Checked = true;
- this.cbCanCheck.CheckState = System.Windows.Forms.CheckState.Checked;
- this.cbCanCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbCanCheck.Location = new System.Drawing.Point(120, 48);
- this.cbCanCheck.Name = "cbCanCheck";
- this.cbCanCheck.Size = new System.Drawing.Size(104, 16);
- this.cbCanCheck.TabIndex = 5;
- this.cbCanCheck.Text = "CanCheck";
- //
- // cbCanEdit
- //
- this.cbCanEdit.Checked = true;
- this.cbCanEdit.CheckState = System.Windows.Forms.CheckState.Checked;
- this.cbCanEdit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbCanEdit.Location = new System.Drawing.Point(120, 28);
- this.cbCanEdit.Name = "cbCanEdit";
- this.cbCanEdit.Size = new System.Drawing.Size(104, 16);
- this.cbCanEdit.TabIndex = 4;
- this.cbCanEdit.Text = "CanEdit";
- //
- // cbuseColumns
- //
- this.cbuseColumns.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbuseColumns.Location = new System.Drawing.Point(120, 8);
- this.cbuseColumns.Name = "cbuseColumns";
- this.cbuseColumns.Size = new System.Drawing.Size(104, 16);
- this.cbuseColumns.TabIndex = 3;
- this.cbuseColumns.Text = "usecolumns ?";
- this.cbuseColumns.CheckedChanged += new System.EventHandler(this.cbuseColumns_CheckedChanged);
- //
- // cbHGridLine
- //
- this.cbHGridLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbHGridLine.Location = new System.Drawing.Point(16, 40);
- this.cbHGridLine.Name = "cbHGridLine";
- this.cbHGridLine.Size = new System.Drawing.Size(104, 16);
- this.cbHGridLine.TabIndex = 2;
- this.cbHGridLine.Text = "ShowGridlines ?";
- this.cbHGridLine.CheckedChanged += new System.EventHandler(this.cbGridLine_CheckedChanged);
- //
- // cbShowTreeLines
- //
- this.cbShowTreeLines.Checked = true;
- this.cbShowTreeLines.CheckState = System.Windows.Forms.CheckState.Checked;
- this.cbShowTreeLines.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbShowTreeLines.Location = new System.Drawing.Point(16, 24);
- this.cbShowTreeLines.Name = "cbShowTreeLines";
- this.cbShowTreeLines.Size = new System.Drawing.Size(112, 16);
- this.cbShowTreeLines.TabIndex = 1;
- this.cbShowTreeLines.Text = "ShowTreeLines ?";
- this.cbShowTreeLines.CheckedChanged += new System.EventHandler(this.cbShowTreeLines_CheckedChanged);
- //
- // cbShowHeader
- //
- this.cbShowHeader.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
- this.cbShowHeader.Location = new System.Drawing.Point(16, 8);
- this.cbShowHeader.Name = "cbShowHeader";
- this.cbShowHeader.Size = new System.Drawing.Size(104, 16);
- this.cbShowHeader.TabIndex = 0;
- this.cbShowHeader.Text = "ShowHeader ?";
- this.cbShowHeader.CheckedChanged += new System.EventHandler(this.cbShowHeader_CheckedChanged);
- //
- // splitter1
- //
- this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
- this.splitter1.Location = new System.Drawing.Point(0, 72);
- this.splitter1.Name = "splitter1";
- this.splitter1.Size = new System.Drawing.Size(520, 3);
- this.splitter1.TabIndex = 1;
- this.splitter1.TabStop = false;
- //
- // pnlTreeview
- //
- this.pnlTreeview.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pnlTreeview.Location = new System.Drawing.Point(0, 75);
- this.pnlTreeview.Name = "pnlTreeview";
- this.pnlTreeview.Size = new System.Drawing.Size(520, 322);
- this.pnlTreeview.TabIndex = 2;
- //
- // contextMenu1
- //
- this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem10});
- //
- // menuItem10
- //
- this.menuItem10.Index = 0;
- this.menuItem10.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem20,
- this.menuItem11,
- this.menuItem12,
- this.menuItem13,
- this.menuItem14,
- this.menuItem15,
- this.menuItem16,
- this.menuItem17,
- this.menuItem18,
- this.menuItem19});
- this.menuItem10.Text = "&Voir";
- //
- // menuItem20
- //
- this.menuItem20.Checked = true;
- this.menuItem20.Index = 0;
- this.menuItem20.Text = "Colonne 0";
- this.menuItem20.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem11
- //
- this.menuItem11.Checked = true;
- this.menuItem11.Index = 1;
- this.menuItem11.Text = "Colonne 1";
- this.menuItem11.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem12
- //
- this.menuItem12.Checked = true;
- this.menuItem12.Index = 2;
- this.menuItem12.Text = "Colonne 2";
- this.menuItem12.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem13
- //
- this.menuItem13.Checked = true;
- this.menuItem13.Index = 3;
- this.menuItem13.Text = "Colonne 3";
- this.menuItem13.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem14
- //
- this.menuItem14.Checked = true;
- this.menuItem14.Index = 4;
- this.menuItem14.Text = "Colonne 4";
- this.menuItem14.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem15
- //
- this.menuItem15.Checked = true;
- this.menuItem15.Index = 5;
- this.menuItem15.Text = "Colonne 5";
- this.menuItem15.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem16
- //
- this.menuItem16.Checked = true;
- this.menuItem16.Index = 6;
- this.menuItem16.Text = "Colonne 6";
- this.menuItem16.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem17
- //
- this.menuItem17.Checked = true;
- this.menuItem17.Index = 7;
- this.menuItem17.Text = "Colonne 7";
- this.menuItem17.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem18
- //
- this.menuItem18.Checked = true;
- this.menuItem18.Index = 8;
- this.menuItem18.Text = "Colonne 8";
- this.menuItem18.Click += new System.EventHandler(this.ColonneClick);
- //
- // menuItem19
- //
- this.menuItem19.Checked = true;
- this.menuItem19.Index = 9;
- this.menuItem19.Text = "Colonne 9";
- this.menuItem19.Click += new System.EventHandler(this.ColonneClick);
- //
- // DemoTreeView
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.BackColor = System.Drawing.SystemColors.Control;
- this.ClientSize = new System.Drawing.Size(520, 397);
- this.Controls.Add(this.pnlTreeview);
- this.Controls.Add(this.splitter1);
- this.Controls.Add(this.panel1);
- this.Name = "DemoTreeView";
- this.Text = "DemoTreeView";
- this.Load += new System.EventHandler(this.DemoTreeView_Load);
- this.panel1.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
- #endregion
-
- private void DemoTreeView_Load(object sender, EventArgs e)
- {
-
- FTree = new GeniusTreeView();
- FTree.KeyDown +=new KeyEventHandler(FTree_KeyDown);
- FTree.AllowDrop = true;
- FTree.ContextMenu = this.contextMenu1;
- FTree.Dock = DockStyle.Fill;
- this.pnlTreeview.Controls.Add(FTree);
- FTree.BeginUpdate();
- try
- {
- FTree.OnBeginCheck +=new OnCheckDelegate(FTree_OnBeginCheck);
- FTree.OnBeginCollapse +=new OnCollapseDelegate(FTree_OnBeginCollapse);
- FTree.OnBeginExpand +=new OnExpandDelegate(FTree_OnBeginExpand);
- FTree.OnBeginUnCheck +=new OnUnCheckDelegate(FTree_OnBeginUnCheck);
- FTree.OnCanEdit +=new OnCanEditDelegate(FTree_OnCanEdit);
- FTree.OnGetNodeText +=new OnGetNodeTextDelegate(FTree_OnGetNodeText);
- for(int i = 0; i < 10; i++)
- {
- INode n = FTree.Add(null, new DataNode(i));
- if (i % 2 == 0)
- n.State |= NodeState.HasCheck;
- n.Text = "Node " + i.ToString();
- for(int j = 0; j < 10; j++)
- {
- INode n1 = FTree.Add(n, new DataNode(j));
- if (j % 2 == 0)
- n1.State |= NodeState.HasCheck;
- n1.Text = "Node " + i.ToString() + j.ToString();
- if (i== 2 && j == 2)
- n1.State |= NodeState.Signaled;
- if (j == 9)
- FTree.SetVisibleNode(n1, false);
- //n1.State &= ~NodeState.Visible;
- }
- GeniusTreeViewColonne col = FTree.Header.Add();
- col.Titre = "Colonne : " + i.ToString();
- if (i == 0)
- {
- col.BackColor = new GeniusLinearGradientBrush(Color.FromArgb(247,247,247));
- }
- else if (i % 2 == 0)
- col.BackColor = new GeniusLinearGradientBrush(Color.White, Color.LightBlue, 90);
- else
- col.BackColor = new GeniusLinearGradientBrush(Color.Beige);
- }
- }
- finally
- {
- FTree.EndUpdate();
- }
- }
-
- private void cbShowHeader_CheckedChanged(object sender, EventArgs e)
- {
- FTree.ShowHeader = cbShowHeader.Checked;
- }
-
- private void cbShowTreeLines_CheckedChanged(object sender, EventArgs e)
- {
- if (cbShowTreeLines.Checked)
- FTree.PaintOptions |= PaintOptionsEnum.ShowTreeLines;
- else
- FTree.PaintOptions &= (~PaintOptionsEnum.ShowTreeLines);
- }
-
- private void cbGridLine_CheckedChanged(object sender, EventArgs e)
- {
- if (cbHGridLine.Checked)
- FTree.PaintOptions |= (PaintOptionsEnum.ShowHorzGridLines);
- else
- FTree.PaintOptions &= ~(PaintOptionsEnum.ShowHorzGridLines);
- }
-
- private void cbuseColumns_CheckedChanged(object sender, EventArgs e)
- {
- FTree.UseColumns = cbuseColumns.Checked;
- }
-
- private void ColonneClick(object sender, EventArgs e)
- {
- string aText = (sender as MenuItem).Text;
- (sender as MenuItem).Checked = !(sender as MenuItem).Checked;
- aText = aText.Substring(8);
- int aIndex = int.Parse(aText);
- FTree.Header[aIndex].Visible = (sender as MenuItem).Checked;
- }
-
- private void FTree_OnBeginCheck(GeniusTreeView Sender, CheckEventArgs e)
- {
- e.CanCheck = cbCanCheck.Checked;
- }
-
- private void FTree_OnBeginCollapse(GeniusTreeView Sender, CollapseEventArgs e)
- {
-
- }
-
- private void FTree_OnBeginExpand(GeniusTreeView Sender, ExpandEventArgs e)
- {
-
- }
-
- private void FTree_OnBeginUnCheck(GeniusTreeView Sender, UnCheckEventArgs e)
- {
- e.CanUnCheck = cbCanUncheck.Checked;
- }
-
- private void FTree_OnCanEdit(GeniusTreeView Sender, CanEditEventArgs e)
- {
- e.CanEdit = cbCanEdit.Checked;
- }
-
- private void label1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
- {
-
- e.Effect = DragDropEffects.Copy;
- Debug.WriteLine("label1_drageenter = " + e.Effect.ToString() + ":" + e.AllowedEffect.ToString());
- }
-
- private void label1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
- {
- e.Effect = DragDropEffects.Copy;
- }
-
- private void label1_GiveFeedback(object sender, System.Windows.Forms.GiveFeedbackEventArgs e)
- {
- Debug.WriteLine("label1_givefeedback = " + e.Effect.ToString());
- //e.Effect = DragDropEffects.Link;
- }
-
- private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- label1.DoDragDrop(label1, DragDropEffects.All);
- }
-
- private void FTree_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Delete)
- {
- FTree.Delete(FTree.SelectedNode);
- }
- }
-
- private void FTree_OnGetNodeText(GeniusTreeView Sender, NodeTextEventArgs e)
- {
- if (e.ColIndex == 1)
- {
- e.Text = ((DataNode)e.Node.Data).Index.ToString();
- }
- }
-
- private void cbVGridLine_CheckedChanged(object sender, System.EventArgs e)
- {
- if (cbVGridLine.Checked)
- FTree.PaintOptions |= (PaintOptionsEnum.ShowVertGridLines);
- else
- FTree.PaintOptions &= ~(PaintOptionsEnum.ShowVertGridLines);
- }
- }
- class DataNode
- {
- public int Index;
- public DataNode(int n)
- {
- Index = n;
- }
- }
- }
Exemple d'utilisation
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace Genius.Controls
{
/// <summary>
/// Summary description for DemoTreeView.
/// </summary>
public class DemoTreeView : Form
{
private GeniusTreeView FTree;
private Panel panel1;
private Splitter splitter1;
private Panel pnlTreeview;
private CheckBox cbShowHeader;
private CheckBox cbShowTreeLines;
private CheckBox cbuseColumns;
private ContextMenu contextMenu1;
private MenuItem menuItem10;
private MenuItem menuItem11;
private MenuItem menuItem12;
private MenuItem menuItem13;
private MenuItem menuItem14;
private MenuItem menuItem15;
private MenuItem menuItem16;
private MenuItem menuItem17;
private MenuItem menuItem18;
private MenuItem menuItem19;
private MenuItem menuItem20;
private CheckBox cbCanEdit;
private CheckBox cbCanCheck;
private CheckBox cbCanUncheck;
private CheckBox checkBox4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox cbHGridLine;
private System.Windows.Forms.CheckBox cbVGridLine;
/// <summary>
/// Required designer variable.
/// </summary>
private Container components = null;
public DemoTreeView()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.cbVGridLine = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.cbCanUncheck = new System.Windows.Forms.CheckBox();
this.cbCanCheck = new System.Windows.Forms.CheckBox();
this.cbCanEdit = new System.Windows.Forms.CheckBox();
this.cbuseColumns = new System.Windows.Forms.CheckBox();
this.cbHGridLine = new System.Windows.Forms.CheckBox();
this.cbShowTreeLines = new System.Windows.Forms.CheckBox();
this.cbShowHeader = new System.Windows.Forms.CheckBox();
this.splitter1 = new System.Windows.Forms.Splitter();
this.pnlTreeview = new System.Windows.Forms.Panel();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem20 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.menuItem15 = new System.Windows.Forms.MenuItem();
this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem17 = new System.Windows.Forms.MenuItem();
this.menuItem18 = new System.Windows.Forms.MenuItem();
this.menuItem19 = new System.Windows.Forms.MenuItem();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.cbVGridLine);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.checkBox4);
this.panel1.Controls.Add(this.cbCanUncheck);
this.panel1.Controls.Add(this.cbCanCheck);
this.panel1.Controls.Add(this.cbCanEdit);
this.panel1.Controls.Add(this.cbuseColumns);
this.panel1.Controls.Add(this.cbHGridLine);
this.panel1.Controls.Add(this.cbShowTreeLines);
this.panel1.Controls.Add(this.cbShowHeader);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(520, 72);
this.panel1.TabIndex = 0;
//
// cbVGridLine
//
this.cbVGridLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbVGridLine.Location = new System.Drawing.Point(16, 56);
this.cbVGridLine.Name = "cbVGridLine";
this.cbVGridLine.Size = new System.Drawing.Size(103, 16);
this.cbVGridLine.TabIndex = 9;
this.cbVGridLine.Text = "ShowGridlines ?";
this.cbVGridLine.CheckedChanged += new System.EventHandler(this.cbVGridLine_CheckedChanged);
//
// label1
//
this.label1.AllowDrop = true;
this.label1.Location = new System.Drawing.Point(392, 24);
this.label1.Name = "label1";
this.label1.TabIndex = 8;
this.label1.Text = "Drag or Drop";
this.label1.GiveFeedback += new System.Windows.Forms.GiveFeedbackEventHandler(this.label1_GiveFeedback);
this.label1.DragEnter += new System.Windows.Forms.DragEventHandler(this.label1_DragEnter);
this.label1.DragOver += new System.Windows.Forms.DragEventHandler(this.label1_DragOver);
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);
//
// checkBox4
//
this.checkBox4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.checkBox4.Location = new System.Drawing.Point(216, 8);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(104, 16);
this.checkBox4.TabIndex = 7;
this.checkBox4.Text = "usecolumns ?";
//
// cbCanUncheck
//
this.cbCanUncheck.Checked = true;
this.cbCanUncheck.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbCanUncheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbCanUncheck.Location = new System.Drawing.Point(216, 48);
this.cbCanUncheck.Name = "cbCanUncheck";
this.cbCanUncheck.Size = new System.Drawing.Size(104, 16);
this.cbCanUncheck.TabIndex = 6;
this.cbCanUncheck.Text = "CanUncheck";
//
// cbCanCheck
//
this.cbCanCheck.Checked = true;
this.cbCanCheck.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbCanCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbCanCheck.Location = new System.Drawing.Point(120, 48);
this.cbCanCheck.Name = "cbCanCheck";
this.cbCanCheck.Size = new System.Drawing.Size(104, 16);
this.cbCanCheck.TabIndex = 5;
this.cbCanCheck.Text = "CanCheck";
//
// cbCanEdit
//
this.cbCanEdit.Checked = true;
this.cbCanEdit.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbCanEdit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbCanEdit.Location = new System.Drawing.Point(120, 28);
this.cbCanEdit.Name = "cbCanEdit";
this.cbCanEdit.Size = new System.Drawing.Size(104, 16);
this.cbCanEdit.TabIndex = 4;
this.cbCanEdit.Text = "CanEdit";
//
// cbuseColumns
//
this.cbuseColumns.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbuseColumns.Location = new System.Drawing.Point(120, 8);
this.cbuseColumns.Name = "cbuseColumns";
this.cbuseColumns.Size = new System.Drawing.Size(104, 16);
this.cbuseColumns.TabIndex = 3;
this.cbuseColumns.Text = "usecolumns ?";
this.cbuseColumns.CheckedChanged += new System.EventHandler(this.cbuseColumns_CheckedChanged);
//
// cbHGridLine
//
this.cbHGridLine.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbHGridLine.Location = new System.Drawing.Point(16, 40);
this.cbHGridLine.Name = "cbHGridLine";
this.cbHGridLine.Size = new System.Drawing.Size(104, 16);
this.cbHGridLine.TabIndex = 2;
this.cbHGridLine.Text = "ShowGridlines ?";
this.cbHGridLine.CheckedChanged += new System.EventHandler(this.cbGridLine_CheckedChanged);
//
// cbShowTreeLines
//
this.cbShowTreeLines.Checked = true;
this.cbShowTreeLines.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbShowTreeLines.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbShowTreeLines.Location = new System.Drawing.Point(16, 24);
this.cbShowTreeLines.Name = "cbShowTreeLines";
this.cbShowTreeLines.Size = new System.Drawing.Size(112, 16);
this.cbShowTreeLines.TabIndex = 1;
this.cbShowTreeLines.Text = "ShowTreeLines ?";
this.cbShowTreeLines.CheckedChanged += new System.EventHandler(this.cbShowTreeLines_CheckedChanged);
//
// cbShowHeader
//
this.cbShowHeader.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.cbShowHeader.Location = new System.Drawing.Point(16, 8);
this.cbShowHeader.Name = "cbShowHeader";
this.cbShowHeader.Size = new System.Drawing.Size(104, 16);
this.cbShowHeader.TabIndex = 0;
this.cbShowHeader.Text = "ShowHeader ?";
this.cbShowHeader.CheckedChanged += new System.EventHandler(this.cbShowHeader_CheckedChanged);
//
// splitter1
//
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Location = new System.Drawing.Point(0, 72);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(520, 3);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// pnlTreeview
//
this.pnlTreeview.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlTreeview.Location = new System.Drawing.Point(0, 75);
this.pnlTreeview.Name = "pnlTreeview";
this.pnlTreeview.Size = new System.Drawing.Size(520, 322);
this.pnlTreeview.TabIndex = 2;
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem10});
//
// menuItem10
//
this.menuItem10.Index = 0;
this.menuItem10.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem20,
this.menuItem11,
this.menuItem12,
this.menuItem13,
this.menuItem14,
this.menuItem15,
this.menuItem16,
this.menuItem17,
this.menuItem18,
this.menuItem19});
this.menuItem10.Text = "&Voir";
//
// menuItem20
//
this.menuItem20.Checked = true;
this.menuItem20.Index = 0;
this.menuItem20.Text = "Colonne 0";
this.menuItem20.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem11
//
this.menuItem11.Checked = true;
this.menuItem11.Index = 1;
this.menuItem11.Text = "Colonne 1";
this.menuItem11.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem12
//
this.menuItem12.Checked = true;
this.menuItem12.Index = 2;
this.menuItem12.Text = "Colonne 2";
this.menuItem12.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem13
//
this.menuItem13.Checked = true;
this.menuItem13.Index = 3;
this.menuItem13.Text = "Colonne 3";
this.menuItem13.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem14
//
this.menuItem14.Checked = true;
this.menuItem14.Index = 4;
this.menuItem14.Text = "Colonne 4";
this.menuItem14.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem15
//
this.menuItem15.Checked = true;
this.menuItem15.Index = 5;
this.menuItem15.Text = "Colonne 5";
this.menuItem15.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem16
//
this.menuItem16.Checked = true;
this.menuItem16.Index = 6;
this.menuItem16.Text = "Colonne 6";
this.menuItem16.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem17
//
this.menuItem17.Checked = true;
this.menuItem17.Index = 7;
this.menuItem17.Text = "Colonne 7";
this.menuItem17.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem18
//
this.menuItem18.Checked = true;
this.menuItem18.Index = 8;
this.menuItem18.Text = "Colonne 8";
this.menuItem18.Click += new System.EventHandler(this.ColonneClick);
//
// menuItem19
//
this.menuItem19.Checked = true;
this.menuItem19.Index = 9;
this.menuItem19.Text = "Colonne 9";
this.menuItem19.Click += new System.EventHandler(this.ColonneClick);
//
// DemoTreeView
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(520, 397);
this.Controls.Add(this.pnlTreeview);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel1);
this.Name = "DemoTreeView";
this.Text = "DemoTreeView";
this.Load += new System.EventHandler(this.DemoTreeView_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void DemoTreeView_Load(object sender, EventArgs e)
{
FTree = new GeniusTreeView();
FTree.KeyDown +=new KeyEventHandler(FTree_KeyDown);
FTree.AllowDrop = true;
FTree.ContextMenu = this.contextMenu1;
FTree.Dock = DockStyle.Fill;
this.pnlTreeview.Controls.Add(FTree);
FTree.BeginUpdate();
try
{
FTree.OnBeginCheck +=new OnCheckDelegate(FTree_OnBeginCheck);
FTree.OnBeginCollapse +=new OnCollapseDelegate(FTree_OnBeginCollapse);
FTree.OnBeginExpand +=new OnExpandDelegate(FTree_OnBeginExpand);
FTree.OnBeginUnCheck +=new OnUnCheckDelegate(FTree_OnBeginUnCheck);
FTree.OnCanEdit +=new OnCanEditDelegate(FTree_OnCanEdit);
FTree.OnGetNodeText +=new OnGetNodeTextDelegate(FTree_OnGetNodeText);
for(int i = 0; i < 10; i++)
{
INode n = FTree.Add(null, new DataNode(i));
if (i % 2 == 0)
n.State |= NodeState.HasCheck;
n.Text = "Node " + i.ToString();
for(int j = 0; j < 10; j++)
{
INode n1 = FTree.Add(n, new DataNode(j));
if (j % 2 == 0)
n1.State |= NodeState.HasCheck;
n1.Text = "Node " + i.ToString() + j.ToString();
if (i== 2 && j == 2)
n1.State |= NodeState.Signaled;
if (j == 9)
FTree.SetVisibleNode(n1, false);
//n1.State &= ~NodeState.Visible;
}
GeniusTreeViewColonne col = FTree.Header.Add();
col.Titre = "Colonne : " + i.ToString();
if (i == 0)
{
col.BackColor = new GeniusLinearGradientBrush(Color.FromArgb(247,247,247));
}
else if (i % 2 == 0)
col.BackColor = new GeniusLinearGradientBrush(Color.White, Color.LightBlue, 90);
else
col.BackColor = new GeniusLinearGradientBrush(Color.Beige);
}
}
finally
{
FTree.EndUpdate();
}
}
private void cbShowHeader_CheckedChanged(object sender, EventArgs e)
{
FTree.ShowHeader = cbShowHeader.Checked;
}
private void cbShowTreeLines_CheckedChanged(object sender, EventArgs e)
{
if (cbShowTreeLines.Checked)
FTree.PaintOptions |= PaintOptionsEnum.ShowTreeLines;
else
FTree.PaintOptions &= (~PaintOptionsEnum.ShowTreeLines);
}
private void cbGridLine_CheckedChanged(object sender, EventArgs e)
{
if (cbHGridLine.Checked)
FTree.PaintOptions |= (PaintOptionsEnum.ShowHorzGridLines);
else
FTree.PaintOptions &= ~(PaintOptionsEnum.ShowHorzGridLines);
}
private void cbuseColumns_CheckedChanged(object sender, EventArgs e)
{
FTree.UseColumns = cbuseColumns.Checked;
}
private void ColonneClick(object sender, EventArgs e)
{
string aText = (sender as MenuItem).Text;
(sender as MenuItem).Checked = !(sender as MenuItem).Checked;
aText = aText.Substring(8);
int aIndex = int.Parse(aText);
FTree.Header[aIndex].Visible = (sender as MenuItem).Checked;
}
private void FTree_OnBeginCheck(GeniusTreeView Sender, CheckEventArgs e)
{
e.CanCheck = cbCanCheck.Checked;
}
private void FTree_OnBeginCollapse(GeniusTreeView Sender, CollapseEventArgs e)
{
}
private void FTree_OnBeginExpand(GeniusTreeView Sender, ExpandEventArgs e)
{
}
private void FTree_OnBeginUnCheck(GeniusTreeView Sender, UnCheckEventArgs e)
{
e.CanUnCheck = cbCanUncheck.Checked;
}
private void FTree_OnCanEdit(GeniusTreeView Sender, CanEditEventArgs e)
{
e.CanEdit = cbCanEdit.Checked;
}
private void label1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
Debug.WriteLine("label1_drageenter = " + e.Effect.ToString() + ":" + e.AllowedEffect.ToString());
}
private void label1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
private void label1_GiveFeedback(object sender, System.Windows.Forms.GiveFeedbackEventArgs e)
{
Debug.WriteLine("label1_givefeedback = " + e.Effect.ToString());
//e.Effect = DragDropEffects.Link;
}
private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
label1.DoDragDrop(label1, DragDropEffects.All);
}
private void FTree_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
FTree.Delete(FTree.SelectedNode);
}
}
private void FTree_OnGetNodeText(GeniusTreeView Sender, NodeTextEventArgs e)
{
if (e.ColIndex == 1)
{
e.Text = ((DataNode)e.Node.Data).Index.ToString();
}
}
private void cbVGridLine_CheckedChanged(object sender, System.EventArgs e)
{
if (cbVGridLine.Checked)
FTree.PaintOptions |= (PaintOptionsEnum.ShowVertGridLines);
else
FTree.PaintOptions &= ~(PaintOptionsEnum.ShowVertGridLines);
}
}
class DataNode
{
public int Index;
public DataNode(int n)
{
Index = n;
}
}
}
Conclusion
cette version 0.1.6 - le drag'n drop conserve encore quelques bugs - pas de multi-selection nb: les sources seront disponible lors de la version 1.0 une version beaucoup plus récente se trouve sur codeplex : http://www.codeplex.com/geniustreeview/
Historique
- 05 mai 2008 21:50:00 :
- mis à jour du lien vers codeplex
http://www.codeplex.com/geniustreeview/
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Listview et dotnet (application smartdevices csharp) [ par medisi ]
Y'a t il une solution pour que listview accepte des couleur (BackgroundColor,ForeColor)dans une application smartdevices (pocket pc).Merci pour votre
Csharp treeView [ par sympatie0 ]
Salut à tous, je suis debutante Csharp et je voudrai savoir comment faire pour utiliser le controle treeView pr afficher les disques locaux et mes d
treeView+nom de la session [ par sympatie0 ]
Salut à tous, Dans le but de construire un treeView afin de donner la possibilité à l'utilisateur de localiser l'emplacement de son dossier sacha
recupere last_insert_id avec mysql en csharp [ par olibara ]
BonjourQuelqu'un sait-il comment depuis cSharp je peux utiliser la commandeselect Last_insert_id() de mysqlPour recuperer cet ID
Drag & Drop de ListView a TreeView [ par gbourgeois0019 ]
Bonjour à tous, J'ai un petit problème que je n'arrive pas à résoudre. J'ai fait des recherches un peu partout mais je n'arrive pas à trouver ce que
[WPF] Récupérer le Parent d'un SelectedItem d'un Treeview bindé? [ par Chris_LaFouine ]
Bonjour,Je suis en train de migrer une de mes applis perso en .NET 3.5 avec interface en XAML et je suis bloqué!Ce que je cherche à faire :Récupérer l
treeview [ par verbeyst ]
J'aimerais implémenter un treeview qui remplirait les mêmes fonctionnalités l'explorateur windows version simplifiée. En d'autres termes je voudrais
Création de node dans un Treeview?? [ par motardazerty ]
Bon bah je crois que tout est dit dans le titre, je le répète quand même:Donc je voudrais créer des Nodes dans un treeView (enfant/parent).Es ce que q
redimentionner les images du TreeView [ par __salwa ]
Bonjour tout le monde, J'ai un treeview qui affiche de images en utilisant un objet ImageList. je voudrai savoir s'il ya un moyen de redimentionner
Framework dotnet [ par GBadry ]
Salut encore une fois les amis,lorsque je déploie un projet et que je l'installe sur une autre machine, normalement toutes les dépendances du projet y
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|