2012-08-09 50 views
1

我正在開發一個WinCE 6.0項目(Compact Framework 3.5)。現在我正在嘗試更改ListView控件的樣式(滾動條)。但我不能畫出自己的風格,因爲沒有.OwnerDraw()方法。用CF 3.5可以自定義ListView的樣式嗎? (特別是滾動條樣式和選定的項目背景顏色)。使用緊湊框架3.5設計ListView Controle

回答

1

這種方法從繼承的ListView刪除滾動條:

const int GWL_STYLE = -16; 
//No ScrollBar 
const int LVS_NOSCROLL = 0x2000; 
private bool noScrollBar = false; 
    public bool NoScrollBar 
    { 
     get { return noScrollBar; } 
     set 
     { 
      noScrollBar = value; 
      int style = (int)NativeMethods.GetWindowLong(Handle, GWL_STYLE); 
      if (noScrollBar) 
      { 
       NativeMethods.SetWindowLong(Handle, GWL_STYLE, style | LVS_NOSCROLL); 
      } 
      else 
      { 
       NativeMethods.SetWindowLong(Handle, GWL_STYLE, style & ~LVS_NOSCROLL); 
      } 
     } 
    } 

也許你可以編輯您的需求。