GridView 隐藏某中得些列.并在HeadText上显示相关的信息
2008-03-03 21:59
323 查看
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
private void ShowInformation()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataTable dt = oss.GetOutStoreSearchResult(oss);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
bb = this.gvOutStore.ControlStyle.Height;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (dt.Rows.Count == 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AddDummyData(dt); //如果没有数据时,添加一列空值
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 1; i < gvOutStore.Columns.Count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.Columns[i].Visible = false; //这个是把除第一列以外得所有列都隐藏起来
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.Columns[0].HeaderText = "显示标题。<table style="vertical-align: bottom; width: 100%; text-align: left"><tr><td align="left" >暂无XXXX信息。</td></tr>";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.ControlStyle.Height = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.hfOutStoreID.Value = "-1";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 1; i < gvOutStore.Columns.Count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.Columns[i].Visible = true; //显示所以已经隐藏起来得列.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//this.gvOutStore.ControlStyle.Height = bb;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.Columns[0].HeaderText = "";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.DataSource = dt;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.gvOutStore.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
//如果为空得时候就添加一行空得记录
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
private void AddDummyData(DataTable dt)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataRow newRow = dt.NewRow();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dt.Rows.Add(newRow);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
我想还有好多其它方法可以做到这一点.
这种法子还有一个缺点是,它得高度不知道怎么弄,我测试了一下,目前还没有发现在什么问题。
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1540979
相关文章推荐
- GridView 隐藏某中得些列.并在HeadText上显示相关的信息
- GridView 隐藏某中得些列.并在HeadText上显示相关的信息
- 在GridView的页脚中显示统计信息
- 基于JQuery的浮动DIV显示提示信息并自动隐藏
- gridView显示隐藏列的值
- 让finder显示隐藏文件,删除SVN信息的终端命令
- Android 定义全局LOG打印日志,并显示调用者相关信息
- GridView显示隐藏某一列?
- 用lua给wxEditor扩展显示相关变量信息
- asp.net后台对sql语句排序,筛选,gridview隐藏过长的字符串鼠标放上去显示全部,dropdownlist在前台显示拼接字符串
- 在地图上点击一下,在图层上画一个点,并显示相关的信息
- .Net中GridView如何隐藏过长的内容显示
- 自定义DevExpress GridView Group时显示项目详细信息
- DataGrid利用DataRelation显示主从表信息(可控制从表信息隐藏和显示).(DataGrid 嵌套)
- GridView信息太长,只显示部分信息,移上去显示全部
- FireFox下GridView表格线显示、隐藏的问题
- 在昨天作业的基础上添加 :删除按钮,修改并保存按钮 和 添加按钮。完成这些按钮所对应的功能/新建页面DataXML,使用GridView显示book.xm中的图书信息
- PowerShell 2.0 CTP Out-GridView: 在数据网格中显示信息
- JQuery 浮动DIV显示提示信息并自动隐藏
- Linux显示网络相关信息