设置DataGridView的滚动条宽度 [英] Set the Scrollbar width of a DataGridView

查看:211
本文介绍了设置DataGridView的滚动条宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为移动设备开发应用程序,并希望将datagrid滚动条按钮变大以增强触摸屏的可用性.我不想更改系统设置窗口的显示属性,因为这会影响整个设备.

是否有一种简单的方法可以更改数据网格视图上滚动条的宽度?

解决方案

我认为您必须自己动手.不过不用担心,它应该没有那么难.我说不应该,因为自从完成.NET CF UI(从臀部射击)以来已经有一段时间了,但是已经为.NET 2.0触摸屏UI实现了自定义滚动条.

也就是说,这是您需要做的:

  • 在网格视图中隐藏滚动条
  • 创建一个自定义控件,其中包含两个按钮,一个顶部,一个底部
  • 处理这些按钮上的点击,并将其作为上/下滚动调用转发到网格视图

这是简单的方法.您不会得到任何拖累,但是在如此小的用户界面中却很少有用.您也可以稍后再放入.

注意事项:网格视图可能没有公开ScrollUp/Down API.在这种情况下,您需要将自定义控件覆盖在显示滚动条的网格视图上方.您可以使用自定义控件隐藏内置的滚动条,而无需调用ScrollUp/Down,而是将Windows消息发布到自定义控件后面的区域,以假"单击并获得网格视图以您喜欢的方式移动.

嗯.我假设使用.NET Compact Framework,因为您提到它是针对移动设备的.它是CF吗?如果没有的话,一切应该都变得简单一些.

编辑

此处自定义网格滚动的基本示例!

I'm working on an app for a mobile device and would like to make a datagrid scrollbar button larger to enhance the touch screen usability. I do not want to alter the system settings windows display properties as this will affect the device as a whole.

Is there an easy way to alter the width of the scrollbar on a datagrid view?

解决方案

i think you'll have to roll your own. Not to worry though, it shouldn't be that hard. i say shouldn't because it's been a while since i've done .NET CF UI (shooting from the hip) but have implemented a custom scroller for a .NET 2.0 touch screen UI.

That said, here's what you need to do:

  • Hide the scroll bars in the grid view
  • Create a custom control which hosts two buttons, one top, one bottom
  • Handle the clicks on those buttons and forward them as scroll up/down calls to the grid view

That's the simple way. You don't get the dragging and stuff but that's rarely useful in such a tiny UI anyway. You could also put in later if you want.

Caveat: The grid view might not have ScrollUp/Down APIs exposed. In that case you'll need to overlay your custom control on top of the grid view which will have the scroll bars shown. You hide the built-in scroll bars with your custom control and instead of calling ScrollUp/Down you post windows messages to the area behind your custom control to "fake" clicks and get the grid view to move around the way you like.

Hmm. i was assuming .NET Compact Framework since you mentioned it's for a mobile device... Is it CF? If not, everything ought to be a little easier.

EDIT

Basic sample of custom grid scrolling here!

这篇关于设置DataGridView的滚动条宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆