关于datagrid的多个问题 [英] Multiple questions on datagrid

查看:66
本文介绍了关于datagrid的多个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我刚开始使用数据网格,我有几个问题...

1.如何自动调整列到以编程方式拟合内容?当你在两个列之间双击时,你会得到左边的一个自动调整到它的内容,当我加载网格时,我想这样做数据。


2.如何使用命令按钮对网格进行排序?单击

列标题时,您将按升序/降序排序网格,我的

用户需要使用按钮执行此操作。


3.如何导航到网格中的新记录?我的用户要求

有一个按钮新记录这将把焦点设置为*标记的行'

第一列。


任何帮助表示赞赏

问候

Kejpa

Hi,
I''ve just started using the datagrid and I have a few questions on it...
1. How do you autosize the columns to fit the content programmatically? When
you double click between two columns you''ll get the left one autosized to
it''s content, I want to do that when I load the grid with data.

2. How do you sort the grid using a command button? When you click the
column header you will get the grid sorted in ascending/descending order, my
users require to do this with a button.

3. How do I navigate to the new record in the grid? My users require that
there is a button "New record" that will set focus to the * marked row''s
first column.

Any help appreciated
Regards
Kejpa

推荐答案

Kepja,


Windowforms datagrid或Webform Datagrid?


Cor


" Kejpa" < kS ******* @ saj.fi>
Kepja,

Windowforms datagrid or Webform Datagrid?

Cor

"Kejpa" <kS*******@saj.fi>
我刚刚开始使用数据网格,我有几个问题......
1.如何自动调整列的大小以便以编程方式拟合内容?
当您在两列之间双击时,您将左侧的列自动调整为
它的内容,当我用数据加载网格时,我想这样做。

2.如何使用命令按钮对网格进行排序?当您单击
列标题时,您将获得按升序/降序排列的网格,
我的
用户需要使用按钮执行此操作。

3。如何导航到网格中的新记录?我的用户要求
有一个按钮新记录。这将把重点放在*标记行的'
第一栏。

任何帮助表示赞赏
Kejpa
I''ve just started using the datagrid and I have a few questions on it...
1. How do you autosize the columns to fit the content programmatically?
When
you double click between two columns you''ll get the left one autosized to
it''s content, I want to do that when I load the grid with data.

2. How do you sort the grid using a command button? When you click the
column header you will get the grid sorted in ascending/descending order,
my
users require to do this with a button.

3. How do I navigate to the new record in the grid? My users require that
there is a button "New record" that will set focus to the * marked row''s
first column.

Any help appreciated
Regards
Kejpa



对于混淆抱歉,Windowsforms Datagrid。
Sorry for the confusion, Windowsforms Datagrid.


>我刚刚开始使用数据网格,我有几个问题...
> I''ve just started using the datagrid and I have a few questions on it...
1.如何自动调整列以便以编程方式拟合内容?
何时
你在两列之间双击你会得到左边一个自动调整它的内容,我想在我加载网格数据时这样做。


使用列样式

Dim g As Graphics = Graphics.FromHwnd(datagrid1.Handle)

column.width = Cint( 10 * CInt(g.MeasureString(" ABCDEFGHIJKLMNOPQRSTUVWXYZ",

Me.Font).Width / 26.0!))

2.如何使用a排序网格命令按钮?当您单击
列标题时,您将获得按升序/降序排列的网格,
我的
用户需要使用按钮执行此操作。


你使用数据视图作为数据源并设置比右边的排序



dim dv作为新数据视图( mytable)

dv.sort =无论什么

datagrid1.datasource = dv

续订时,首先要将数据源设置为空

3.如何导航到网格中的新记录?我的用户要求
有一个按钮新记录。这将把焦点设置到*标记行的'
第一列。
1. How do you autosize the columns to fit the content programmatically?
When
you double click between two columns you''ll get the left one autosized to
it''s content, I want to do that when I load the grid with data.
Using column styles
Dim g As Graphics = Graphics.FromHwnd(datagrid1.Handle)
column.width = Cint(10 * CInt(g.MeasureString("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
Me.Font).Width / 26.0!))
2. How do you sort the grid using a command button? When you click the
column header you will get the grid sorted in ascending/descending order,
my
users require to do this with a button.
You use a dataview as the datasource and set than the sort to the right
column
dim dv as new dataview(mytable)
dv.sort = whatever
datagrid1.datasource = dv
When you renew it you have first to set the datasource to nothing
3. How do I navigate to the new record in the grid? My users require that
there is a button "New record" that will set focus to the * marked row''s
first column.




通过继承它自己成为一个新的数据网格来尝试它,而不是*

问题很简单,所以很难找到现成的数据网格

互联网。


我希望这会有所帮助?


Cor



Try it by making yourself a new datagrid by inheriting it, without the *
question it is easy, so probably hard to find as a ready made datagrid on
internet.

I hope this helps?

Cor


这篇关于关于datagrid的多个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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