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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#ListBox學習筆記

學習C# ListBox使用,僅當 DrawMode 屬性設置為 DrawMode.OwnerDrawFixed 或 DrawMode.OwnerDrawVariable 時,才引發(fā)該事件??梢允褂迷撌录韴?zhí)行在C# ListBox 中繪制項所需的任務。如果具有大小可變的項(當 DrawMode 屬性設置為 DrawMode.OwnerDrawVariable 時),在繪制項前,引發(fā) MeasureItem 事件。可以為 MeasureItem 事件創(chuàng)建事件處理程序,以在 DrawItem 事件的事件處理程序中指定要繪制的項的大小。有關處理事件的更多信息,請參見 使用事件。

站在用戶的角度思考問題,與客戶深入溝通,找到六枝網(wǎng)站設計與六枝網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:做網(wǎng)站、網(wǎng)站設計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、國際域名空間、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務覆蓋六枝地區(qū)。

重寫C# Listbox的drawitem事件

 
 
 
  1. privatevoidlistBox1_DrawItem(objectsender,System.Windows.Forms.DrawItemEventArgse){
  2. //SettheDrawModepropertytodrawfixedsizeditems.
  3. listBox1.DrawMode=DrawMode.OwnerDrawFixed;
  4. //DrawthebackgroundoftheListBoxcontrolforeachitem.
  5. e.DrawBackground();
  6. //Definethedefaultcolorofthebrushasblack.
  7. BrushmyBrush=Brushes.Black;
  8. //Determinethecolorofthebrushtodraweachitembasedontheindexoftheitemtodraw.
  9. switch(e.Index){
  10. case0:myBrush=Brushes.Red;break;
  11. case1:myBrush=Brushes.Orange;break;
  12. case2:myBrush=Brushes.Purple;break;
  13. }
  14. //DrawthecurrentitemtextbasedonthecurrentFontandthecustombrushsettings.
  15. e.Graphics.DrawString(listBox1.Items[e.Index].ToString(),e.Font,myBrush,
  16. e.Bounds,StringFormat.GenericDefault);
  17. //IftheListBoxhasfocus,drawafocusrectanglearoundtheselecteditem.
  18. e.DrawFocusRectangle();
  19. }

從這個例子,我們發(fā)現(xiàn)在C#下面重畫控件,比在vc++6.0中定義自繪方便多了


當前名稱:C#ListBox學習筆記
當前路徑:http://www.dlmjj.cn/article/djdhgjc.html