简单问题 - 数据网格和类型化数据集 [英] Simple Question - Datagrid and Typed dataset

查看:74
本文介绍了简单问题 - 数据网格和类型化数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了很多搜索并阅读了一些关于

datagrids的内容。但我无法找到我简单的问题的答案,我怎样才能在表中显示我想要的

列?例如,我写了这个SQL查询:

OleDbDataAdapter1.SelectCommand.CommandText =& _

"从tblIllness中选择illNameE"

OleDbDataAdapter1.Fill(DsIllness1)


但是在我的数据网格中,我得到了( null)对于其他ccolumns而不是
隐藏不受欢迎的列。


另一个问题:数据网格是windows窗体中的最佳选择

to显示可点击列表数据?


TIA

-

Sabre S.
http://maghalat.com

I did a lot of searches and read something about
datagrids. But I couldn''t find the answer of my simple
question, how can I show only my desired columns of
a table? for example I wrote this sql query:

OleDbDataAdapter1.SelectCommand.CommandText = & _
"Select illNameE From tblIllness"
OleDbDataAdapter1.Fill(DsIllness1)

But in my datagrid, I get (null) for other ccolumns instead
of hiding undesired columns.

Another question: Is datagrid best choice in windows form
to show a list of "clickable" data?

TIA
--
Saber S.
http://maghalat.com

推荐答案

我是推测你指的是你比一列数据拉更多的情况。


你可能根本就没有在你的查询中选择那些列。 />

但如果你这样做,你可以使用MappingType.Hidden隐藏网格中的那些:


ds.Tables(" dtCosts")。列(SalesID)。ColumnMapp ing = MappingType.Hidden


" Sabre" <马刀[.AT。] oxin.ir>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
I''m speculating that you are referring to situations where you pull more
than one column of data.

You could simply not Select those columns in your query.

But if you do, you could use MappingType.Hidden to hide those in the grid:

ds.Tables("dtCosts").Columns("SalesID").ColumnMapp ing = MappingType.Hidden

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
我做过很多搜索和阅读有关数据网格的东西。但是我找不到简单问题的答案,我怎么能只显示我想要的一张桌子呢?例如我写了这个SQL查询:

OleDbDataAdapter1.SelectCommand.CommandText =& _
从tblIllness中选择illNameE
OleDbDataAdapter1.Fill(DsIllness1)

但在我的数据网格中,我得到(null)其他ccolumns而不是隐藏不希望的列。

另一个问题:数据网格是windows窗体中的最佳选择
以显示可点击的列表吗?数据?

TIA
- Sabre S.
http://maghalat.com
I did a lot of searches and read something about
datagrids. But I couldn''t find the answer of my simple
question, how can I show only my desired columns of
a table? for example I wrote this sql query:

OleDbDataAdapter1.SelectCommand.CommandText = & _
"Select illNameE From tblIllness"
OleDbDataAdapter1.Fill(DsIllness1)

But in my datagrid, I get (null) for other ccolumns instead
of hiding undesired columns.

Another question: Is datagrid best choice in windows form
to show a list of "clickable" data?

TIA
--
Saber S.
http://maghalat.com



使用数据网格,如果设置要隐藏的列的列宽

为0或者你不能为它们提供ColumnMapping。看看这个

http:// www。 knowdotnet.com/articles/cgrid.html - 包含它的

的代码将告诉你如何做你想做的大部分工作
$ b带网格的$ b ..还有一个NullText属性,你可以为每个列设置

,它有DataGridColumnStyle,它将替换你指定的值

而不是显示(Null)虽然整个问题都是yoru的声音,

你不想要一个值,你想隐藏这个列。


无论如何,就最好而言,这取决于很多事情,但就可点击数据列表而言,实际上,网格可能不是那么好的

a选择。开箱即用它具有排序功能,但是如果你绑定到一个

DataView而不是DataTable,它很容易通过代码实现。

原因我说这是b / c如果你在列表中只有一列,那么网格

有很多额外的箍你需要跳过来获得给定值

a ListBox或ComboBox不是(不是我说它''很难'',我只是认为

对于列表中的可点击功能 - 列表框或者在大多数情况下,ComboBox可能是一个更好的选择。对于单个列列表,一个Listbox可能是更好的选择b / c b / c你可以引用它们点击的内容

with SelectedItem和SelectedValue(记得设置DisplayMember和

ValueMembers - 这样,你可以显示一个值,但使用不同的值 -

这是一个痛苦的网格)

Saber< saber [.AT。] oxin.ir>写在消息中e $>
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
With a datagrid, if you set the column width of the columns you want hidden
to 0 or you can just not provide a ColumnMapping for them. Check out this
class http://www.knowdotnet.com/articles/cgrid.html - the code that''s
included with it will show you how to do most anything you will want to do
with a grid.. There''s also a NullText property you can set for each Column
that has DataGridColumnStyle that will substitute the value you specify
instead of showing (Null) although frm the sound of yoru entire question,
you don''t want a value there, you want the column hidden.

Anyway, as far as ''best'' goes, that depends on a lot of things but as far as
a ''list of clickable data'', actually, the grid probably isnt'' that great of
a choice. Out of the box it has sorting capabilities, but if you bind to a
DataView instead of a DataTable, it''s easy enough to implement through code.
The reason I say this is b/c if you only have one column in a list, the grid
has a lot of extra hoops you need to jump through to get a given value that
a ListBox or ComboBox doesn''t (not that I''m saying it''s ''hard'', I just think
that for clickable funcionality in a list - that the ListBox or ComboBox is
probably a better choice in most cases. A Listbox is probably a better
choice for a single column list b/c you can just reference what they click
with SelectedItem and SelectedValue (remember to set the DisplayMember and
ValueMembers - this way, you can show one value but use a different one -
something which is a pain to do in a grid)
"Saber" <saber[.AT.]oxin.ir> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
我做了很多搜索和阅读有关数据网格的东西。但是我找不到简单问题的答案,我怎么能只显示我想要的一张桌子呢?例如我写了这个SQL查询:

OleDbDataAdapter1.SelectCommand.CommandText =& _
从tblIllness中选择illNameE
OleDbDataAdapter1.Fill(DsIllness1)

但在我的数据网格中,我得到(null)其他ccolumns而不是隐藏不希望的列。

另一个问题:数据网格是windows窗体中的最佳选择
以显示可点击的列表吗?数据?

TIA
- Sabre S.
http://maghalat.com
I did a lot of searches and read something about
datagrids. But I couldn''t find the answer of my simple
question, how can I show only my desired columns of
a table? for example I wrote this sql query:

OleDbDataAdapter1.SelectCommand.CommandText = & _
"Select illNameE From tblIllness"
OleDbDataAdapter1.Fill(DsIllness1)

But in my datagrid, I get (null) for other ccolumns instead
of hiding undesired columns.

Another question: Is datagrid best choice in windows form
to show a list of "clickable" data?

TIA
--
Saber S.
http://maghalat.com



谢谢Earl,

如前所述,如果我不要在查询中选择那些列,我用(null)文本而不是隐藏列来获取

列。

但MappingType.Hidden对我有好处,谢谢那个。


-

Sabre S.
http://maghalat.com

" Earl" <峰; br ****** @ newsgroups.nospam>在留言中写道

新闻:Oi ************** @ TK2MSFTNGP10.phx.gbl ...
Thanks Earl,
As I said before, if I don''t select those columns in query, I get
columns with (null) text instead of hidden columns.
But MappingType.Hidden is good for me, Thanks for that.

--
Saber S.
http://maghalat.com
"Earl" <br******@newsgroups.nospam> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
我在猜测你指的是比一列数据更多的情况。

你可能根本就没有在你的查询中选择那些列。

但如果你你可以使用MappingType.Hidden来隐藏网格中的那些:

ds.Tables(" dtCosts")。列(" SalesID")。ColumnMapp ing = MappingType.Hidden

Sabre <马刀[.AT。] oxin.ir>在消息中写道
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...
I''m speculating that you are referring to situations where you pull more
than one column of data.

You could simply not Select those columns in your query.

But if you do, you could use MappingType.Hidden to hide those in the grid:

ds.Tables("dtCosts").Columns("SalesID").ColumnMapp ing = MappingType.Hidden

"Saber" <saber[.AT.]oxin.ir> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
我做了很多搜索并阅读有关
datagrids的内容。但是我找不到简单问题的答案,我怎么能只显示我想要的一张桌子呢?例如我写了这个SQL查询:

OleDbDataAdapter1.SelectCommand.CommandText =& _
从tblIllness中选择illNameE
OleDbDataAdapter1.Fill(DsIllness1)

但在我的数据网格中,我得到(null)其他ccolumns而不是隐藏不希望的列。

另一个问题:数据网格是windows窗体中的最佳选择
以显示可点击的列表吗?数据?

TIA
- Sabre S.
http://maghalat.com
I did a lot of searches and read something about
datagrids. But I couldn''t find the answer of my simple
question, how can I show only my desired columns of
a table? for example I wrote this sql query:

OleDbDataAdapter1.SelectCommand.CommandText = & _
"Select illNameE From tblIllness"
OleDbDataAdapter1.Fill(DsIllness1)

But in my datagrid, I get (null) for other ccolumns instead
of hiding undesired columns.

Another question: Is datagrid best choice in windows form
to show a list of "clickable" data?

TIA
--
Saber S.
http://maghalat.com




这篇关于简单问题 - 数据网格和类型化数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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