如何删除数据集的列? [英] How can I delete a column of a Dataset?

查看:204
本文介绍了如何删除数据集的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以删除数据集的列?

是否有将做到这一点对我来说这样的方法:

  rh.dsDetail = ds.Tables [0] .Columns.Remove(
 

或许是这样的:

  rh.dsDetail = ds.Tables [0] .Columns.Remove(ds.Tables [0] .Columns [1],ds.Tables [0] .Columns [2] )
 

解决方案

首先,数据表中的列,而不是一个数据集。

如果你想摆脱他们,然后:

  table.Columns.Clear();
 

否则,如果您有索引:

  table.Columns.RemoveAt(0);
 

应该做的工作,如果你有列索引。请注意,如果你删除列0,则该数字将洗牌(所以你可能需要做相反的顺序)。

另外,你可能想通过名称删除:

  table.Columns.Remove(富);
 

How can I delete a column of a Dataset?

Is there a method that will do this for me like this:

rh.dsDetail = ds.Tables[0].Columns.Remove(

Or maybe like this:

rh.dsDetail = ds.Tables[0].Columns.Remove( ds.Tables[0].Columns[1],ds.Tables[0].Columns[2])

解决方案

First, a DataTable has columns, not a data-set.

If you want to get rid of them, then:

table.Columns.Clear();

otherwise, if you have the index:

table.Columns.RemoveAt(0);

should do the job if you have the column index. Note that if you remove column 0, then the numbers will shuffle (so you might need to do in reverse order).

Alternatively, you may want to remove by name:

table.Columns.Remove("Foo");

这篇关于如何删除数据集的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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