2012-08-09 45 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); 
      } 
     } 
    } 

也许你可以编辑您的需求。