成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

ASP.NET控件設計時支持之自動格式設置淺析

開發 后端
ASP.NET控件設計時支持之自動格式設置就是向大家介紹ASP.NET控件設計時支持之自動格式設置的相關實現內容。

ASP.NET控件設計時支持之自動格式設置是如何實現的呢?

先看個圖

自動格式設置 

相信大家都很熟悉吧,我們可以用這個面板很方面的使用預定的樣式.我們可以稱之為自動格式設置或者自動套用樣式.

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

DesignerAutoFormatCollection集合 

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

  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.   } 

這么著效果就實現了,這次比較懶,沒好好寫,還想打算寫別的,就先這樣吧.

ASP.NET控件設計時支持之自動格式設置的相關內容就向你介紹到這里,希望對你了解ASP.NET控件設計時支持之自動格式設置有幫助。

【編輯推薦】

  1. ASP.NET控件開發基礎的總結詳解
  2. ASP.NET模板控件開發淺析
  3. ASP.NET數據綁定控件開發淺析
  4. ASP.NET控件設計時支持淺析
  5. ASP.NET2.0數據源控件的用法淺析
責任編輯:仲衡 來源: 博客園
相關推薦

2009-08-07 16:32:52

ASP.NET控件設計時支

2009-08-07 17:49:44

控件設計器

2009-08-07 17:17:43

ASP.NET控件設計

2009-08-10 13:32:15

ASP.NET TimASP.NET組件設計

2009-08-07 17:59:35

控件設計器

2009-07-27 17:25:53

ASP.NET驗證控件

2009-07-28 16:21:03

Asp.net AjaAutoComplet

2009-08-06 15:21:45

ASP.NET控件開發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 16:53:14

ASP.NET組件設計

2009-08-05 18:46:21

ComboBox顯示ASP.NET控件開發

2009-08-10 14:38:29

ASP.NET組件設計

2009-08-06 09:18:01

ASP.NET自定義控ASP.NET控件開發

2009-08-10 14:08:15

ASP.NET服務器控ASP.NET組件設計

2009-08-04 17:28:45

Apache支持ASP

2009-07-24 09:57:25

ASP.NET HTM

2009-08-04 15:20:59

ASP.NET數據驗證數據驗證控件

2009-08-07 15:34:15

ASP.NET數據綁定
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美福利专区 | 久久亚洲天堂 | 黄a免费看 | 人人鲁人人莫人人爱精品 | 久久男人| 国产精品久久久久久吹潮 | 一区二区三区国产 | 99精品在线观看 | 国产精品久久久久久中文字 | 久久国产精品一区二区三区 | 欧美一区二区三区视频 | 成人教育av | 欧美亚州| 国产剧情久久 | 亚洲一区二区日韩 | 一区二区免费 | 一级毛片在线播放 | 欧美一区二区三区在线视频 | 一区二区三区视频在线观看 | 国产三级网站 | 亚洲福利一区二区 | 国产精品综合色区在线观看 | 中文字幕一二三区 | 国产精品国产三级国产aⅴ无密码 | 中文字幕av中文字幕 | 亚洲精品短视频 | 亚洲一区二区三区四区在线观看 | 国产aaaaav久久久一区二区 | 中文字字幕在线中文乱码范文 | 日韩成人av在线 | 中文在线日韩 | 天天爽天天操 | 精品一区二区三区在线观看 | 国产一区二区在线视频 | 国外成人在线视频 | 国产丝袜一区二区三区免费视频 | 精品久久伊人 | 欧美一区二区三区四区五区无卡码 | www久久av| 日韩高清黄色 | 久久久久久久综合色一本 |