惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
V
V2EX
博客园 - 司徒正美
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
雷峰网
雷峰网
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 聂微东
量子位
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News

博客园 - 左佩玉

通过了 70-316 考试 .NET SDK 工具 线程 进程 程序配置 程序集 全局化和本地化 实现帮助 可访问性设计 访问和调用外部组件 实现打印 自定义控件 使用 GDI+ 在ADO.net 中使用xml ADO.net 处理和抛出异常 使用Debug和Trace 测试和调试 继承 System.Collections.CollectionBase 创建一个强类型集合类
绑定、查看和筛选数据
左佩玉 · 2005-08-22 · via 博客园 - 左佩玉

绑定字符串
    String[] myStrings = new String[3];
    myStrings[0] = "A";
    myStrings[1] = "String";
    myStrings[2] = "Array";
    TextBox1.DataBindings.Add("Text",myStrings,"");

    删除数据绑定
    Label1.DataBindings.Remove(Label1.DataBindings["Text"]);
    Label1.DataBindings.Clear;

数据导航 CurrencyManager对象
    this.BindingContext[DataSet1.Customers];

    this.BindingContext[DataSet1.Customers].Position = 0;
    this.BindingContext[DataSet1.Customers].Position ++;
    this.BindingContext[DataSet1.Customers].Position --;
    this.BindingContext[DataSet1.Customers].Position = 4;  //第五条
    this.BindingContext[DataSet1.Customers].Position =  DataSet1.Tables["Customers"].Rows.Count - 1;

CurrencyManager的PositionChanged事件

数据绑定
ComboBox1.DataSource = DataSet1.Customers;
ComboBox1.DisplayMember = "CustomerID";

使用DataView
DataView myDataView = new DataView();
myDataView.Table = myDataTable;

排序
myDataView.Sort = "CustomerID";
myDataView.Sort = "State DESC, City";

筛选
myDataView.RowFilter = "City = 'Seattle'";
myDataView.RowFilter = "City IN ('Seattle','Tacoma','Blaine')";
myDataView.RowFilter = "City LIKE 'Se*t%e'";

RowState属性
   Unchanged
   Modified
   Added
   Deleted
   Detached  //已创建,不属于任何DataRowCollection
DataView.RowState
   Unchanged
   Added
   Deleted
   OriginalRows
   CurrentRows
   ModifiedCurrent
   ModifiedOriginal

用DataView编辑数据
  AllowDelete     AllowEdit     AllowNew

DataViewManager
DataViewManager myDataViewManager = new DataViewManager(myDataSet);
DataViewManager myOtherDataViewManager = new DataViewManager();
myOtherDataViewManager.DataSet = myOtherDataSet;

myDataViewManager.DataViewSettings["Customers"].RowFilter = "State = 'WA'";
//获取
DataView myDataView = myDataViewManager.CreateDataView(DataSet1.Tables[0]);