自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置淺析

開發(fā) 后端
ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置就是向大家介紹ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置的相關(guān)實(shí)現(xiàn)內(nèi)容。

ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置是如何實(shí)現(xiàn)的呢?

先看個(gè)圖

自動(dòng)格式設(shè)置 

相信大家都很熟悉吧,我們可以用這個(gè)面板很方面的使用預(yù)定的樣式.我們可以稱之為自動(dòng)格式設(shè)置或者自動(dòng)套用樣式.

ControlDesigner類提供了AutoFormats屬性,其提供了DesignerAutoFormat類的DesignerAutoFormatCollection集合.我們來看下相關(guān)的類.

DesignerAutoFormatCollection集合 

ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置中DesignerAutoFormat 是一個(gè)基類,如果你想為你的控件在設(shè)計(jì)時(shí)提供格式化的功能,你可以從此類派生,你必須實(shí)現(xiàn)Apply方法,此方法會(huì)將相關(guān)聯(lián)的控件設(shè)置樣式.由于實(shí)現(xiàn)比較簡單就不再多多了,就直接拿MSDN的例子來看吧. 注意給 IndentLabelDesigner 加上SupportsPreviewControl元數(shù)據(jù),這樣可以支持預(yù)覽功能.

  1. [Designer(typeof(IndentLabelDesigner)),  
  2.       ToolboxData("﹤{0}:IndentLabel Runat=\"server\"﹥﹤/{0}:IndentLabel﹥")]  
  3.   public class IndentLabel : Label  
  4.   {  
  5.       [SupportsPreviewControl(true)]  
  6.       public class IndentLabelDesigner : LabelDesigner  
  7.       {  
  8.           private DesignerAutoFormatCollection _autoFormats = null;  
  9.  
  10.           public override DesignerAutoFormatCollection AutoFormats  
  11.           {  
  12.               get 
  13.               {  
  14.                   if (_autoFormats == null)  
  15.                   {  
  16.                       _autoFormats = new DesignerAutoFormatCollection();  
  17.                       _autoFormats.Add(new IndentLabelAutoFormat("MyClassic"));  
  18.                       _autoFormats.Add(new IndentLabelAutoFormat("MyBright"));  
  19.                       _autoFormats.Add(new IndentLabelAutoFormat("Default"));  
  20.                   }  
  21.                   return _autoFormats;  
  22.               }  
  23.           }  
  24.       }  
  25.  
  26.       private class IndentLabelAutoFormat : DesignerAutoFormat  
  27.       {  
  28.           public IndentLabelAutoFormat(string name)  
  29.               : base(name)  
  30.           { }  
  31.  
  32.           public override void Apply(Control inLabel)  
  33.           {  
  34.               if (inLabel is IndentLabel)  
  35.               {  
  36.                   IndentLabel ctl = (IndentLabel)inLabel;  
  37.  
  38.                   
  39.                   if (this.Name == "MyClassic")  
  40.                   {  
  41.                        
  42.                       ctl.ForeColor = Color.Gray;  
  43.                       ctl.BackColor = Color.LightGray;  
  44.                       ctl.Font.Size = FontUnit.XSmall;  
  45.                       ctl.Font.Name = "Verdana,Geneva,Sans-Serif";  
  46.                   }  
  47.                   else if (this.Name == "MyBright")  
  48.                   {  
  49.                        
  50.                       this.Style.ForeColor = Color.Maroon;  
  51.                       this.Style.BackColor = Color.Yellow;  
  52.                       this.Style.Font.Size = FontUnit.Medium;  
  53.                       ctl.MergeStyle(this.Style);  
  54.                   }  
  55.                   else 
  56.                   {  
  57.                       ctl.ForeColor = Color.Black;  
  58.                       ctl.BackColor = Color.Empty;  
  59.                       ctl.Font.Size = FontUnit.XSmall;  
  60.                   }  
  61.               }  
  62.           }  
  63.       }  
  64.   } 

這么著效果就實(shí)現(xiàn)了,這次比較懶,沒好好寫,還想打算寫別的,就先這樣吧.

ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置的相關(guān)內(nèi)容就向你介紹到這里,希望對你了解ASP.NET控件設(shè)計(jì)時(shí)支持之自動(dòng)格式設(shè)置有幫助。

【編輯推薦】

  1. ASP.NET控件開發(fā)基礎(chǔ)的總結(jié)詳解
  2. ASP.NET模板控件開發(fā)淺析
  3. ASP.NET數(shù)據(jù)綁定控件開發(fā)淺析
  4. ASP.NET控件設(shè)計(jì)時(shí)支持淺析
  5. ASP.NET2.0數(shù)據(jù)源控件的用法淺析
責(zé)任編輯:仲衡 來源: 博客園
相關(guān)推薦

2009-08-07 16:32:52

ASP.NET控件設(shè)計(jì)時(shí)支

2009-08-07 17:49:44

控件設(shè)計(jì)器

2009-08-07 17:17:43

ASP.NET控件設(shè)計(jì)

2009-08-10 13:32:15

ASP.NET TimASP.NET組件設(shè)計(jì)

2009-08-07 17:59:35

控件設(shè)計(jì)器

2009-07-28 16:21:03

Asp.net AjaAutoComplet

2009-07-27 17:25:53

ASP.NET驗(yàn)證控件

2009-08-06 15:21:45

ASP.NET控件開發(fā)RenderConte

2009-08-07 17:41:07

ASP.NET Web

2009-08-07 14:05:21

ASP.NET控件

2009-08-07 15:24:16

ASP.NET模板控件

2009-08-05 18:46:21

ComboBox顯示ASP.NET控件開發(fā)

2009-08-05 16:53:14

ASP.NET組件設(shè)計(jì)

2009-08-06 09:18:01

ASP.NET自定義控ASP.NET控件開發(fā)

2009-08-10 14:08:15

ASP.NET服務(wù)器控ASP.NET組件設(shè)計(jì)

2009-08-10 14:38:29

ASP.NET組件設(shè)計(jì)

2009-08-04 17:28:45

Apache支持ASP

2009-08-07 15:34:15

ASP.NET數(shù)據(jù)綁定

2009-07-24 09:57:25

ASP.NET HTM

2009-08-04 15:20:59

ASP.NET數(shù)據(jù)驗(yàn)證數(shù)據(jù)驗(yàn)證控件
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號