日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳解C#的WinForm增加treeView1控件

Winform中關(guān)于treeView控件的做法,大家都比較了解。本文將談到的是treeView1控件的增加過程,希望對(duì)廣大開發(fā)人員有所幫助。

創(chuàng)新互聯(lián)公司長期為近千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為遂溪企業(yè)提供專業(yè)的成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、外貿(mào)營銷網(wǎng)站建設(shè),遂溪網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。

使用TreeNode的tag屬性放置編碼,TreeNode的Text屬性放置名稱,最簡單的示例如下——先添加兩個(gè)節(jié)點(diǎn),然后處理AfterSelect事件:

 
 
 
  1. using System;   
  2.   using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;   
  3.   namespace testtree   
  4.   {   
  5.   ///    
  6.   /// Form1 的摘要說明。   
  7.   ///    
  8.   public class Form1 : System.Windows.Forms.Form   
  9.   {   
  10.   private System.Windows.Forms.TreeView treeView1;   
  11.   ///    
  12.   /// 必需的設(shè)計(jì)器變量。   
  13.   ///    
  14.   private System.ComponentModel.Container components = null;   
  15.   public Form1()   
  16.   {   
  17.   //   
  18.   // Windows窗體設(shè)計(jì)器支持所必需的   
  19.   //   
  20.   InitializeComponent();   
  21.   //   
  22.   // TODO:在InitializeComponent調(diào)用后添加任何構(gòu)造函數(shù)代碼   
  23.   //   
  24.   TreeNode tn = new TreeNode();   
  25.   tn.Tag = "1001"; tn.Text = "hello";   
  26.   TreeNode tn2 = new TreeNode();   
  27.   tn2.Tag = "1002"; tn2.Text = "ok";   
  28.   tn.Nodes.Add(tn2);   
  29.   treeView1.Nodes.Add(tn);   
  30.   }   
  31.   ///    
  32.   /// 清理所有正在使用的資源。   
  33.   ///    
  34.   protected override void Dispose( bool disposing )   
  35.   {   
  36.   if( disposing )   
  37.   {   
  38.   if (components != null)   
  39.   {   
  40.   components.Dispose();   
  41.   }   
  42.   }   
  43.   base.Dispose( disposing );   
  44.   }   
  45.   #region Windows窗體設(shè)計(jì)器生成的代碼   
  46.   ///    
  47.   ///設(shè)計(jì)器支持所需的方法-不要使用代碼編輯器修改   
  48.   /// 此方法的內(nèi)容。   
  49.   ///    
  50.   private void InitializeComponent()   
  51.   {   
  52.   this.treeView1 = new System.Windows.Forms.TreeView(); this.SuspendLayout();   
  53.   //   
  54.   // treeView1控件   
  55.   //   
  56.   this.treeView1.ImageIndex = -1; this.treeView1.Location = new System.Drawing.Point(16, 8); this.treeView1.Name = "treeView1"; this.treeView1.SelectedImageIndex = -1; this.treeView1.TabIndex = 0; this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);   
  57.   //   
  58.   // Form1   
  59.   //   
  60.   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.treeView1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false);   
  61.   }   
  62.   #endregion   
  63.   ///    
  64.   /// 應(yīng)用程序的主入口點(diǎn)。   
  65.   ///    
  66.   [STAThread]   
  67.   static void Main()   
  68.   {   
  69.   Application.Run(new Form1());   
  70.   }   
  71.   private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)   
  72.   {   
  73.   string s = treeView1.SelectedNode.Tag.ToString(); string s2 = treeView1.SelectedNode.Text.ToString();   
  74.   }   
  75.   }   
  76.   } 

關(guān)于C#的WinForm增加treeView1控件就總結(jié)到這里。


當(dāng)前標(biāo)題:詳解C#的WinForm增加treeView1控件
當(dāng)前地址:http://www.dlmjj.cn/article/dpphisg.html