DataGrid 如何得到DataGridRow 和DataGridCell 对象
第一行为不可编辑
DataGridRow row = (DataGridRow)dataGrid1.ItemContainerGenerator.ContainerFromIndex(0);
if
(row ==
null
)
{
dataGrid1.UpdateLayout();
row = (DataGridRow)dataGrid1.ItemContainerGenerator.ContainerFromIndex(0);
}
row.IsEnabled =
false
;
public
static
T GetVisualChild<T>(Visual parent) where T : Visual
{
T childContent =
default
(T);
int
numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for
(
int
i = 0; i < numVisuals; i++)
{
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
childContent = v
as
T;
if
(childContent ==
null
)
{
childContent = GetVisualChild<T>(v);
}
if
(childContent !=
null
)
{
break
;
}
}
return
childContent;
}
//第二行第一列不可编辑
DataGridRow rowContainer = GetDataGridRow(dataGrid1, 1);
if
(rowContainer !=
null
)
{
DataGridCellsPresenter presenter = GetVisualChild<DataGridCellsPresenter>(rowContainer);
DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(1);
if
(cell ==
null
)
{
dataGrid1.ScrollIntoView(rowContainer, dataGrid1.Columns[0]);
cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(0);
}
cell.IsEnabled =
false
;
}
DataGrid 如何得到DataGridRow 和DataGridCell 对象的更多相关文章
- WPF:获取DataGrid控件单元格DataGridCell
转载:http://blog.csdn.net/jhqin/article/details/7645357 /* ------------------------------------------- ...
- WPF 获得DataGridRow和 DataGridCell的方法
原文:WPF 获得DataGridRow和 DataGridCell的方法 原文地址 简介 在WPF中,DataGrid控件并没有提供访问其DataGridRow或者DataGridCell的方法. ...
- EasyUI 中 DataGrid 控件 列 如何绑定对象中的属性
EasyUI 中 DataGrid 控件 是我们经常用到的控件之一, 但是 DataGrid 控件 在绑定显示列时却不支持对象属性绑定. 模型如下: public class Manager impl ...
- 让Easy UI 的DataGrid直接内嵌的JSON对象,并重写form load 方法
前言 我有这样的JSON对象 { "UserName": "jf", "UserPwd": "123456", &quo ...
- DataGrid 得到DataGridRow 和DataGridColumn
/* ---------------------------------------------------------- 文件名称:DataGridPlus.cs 作者:秦建辉 MSN:splash ...
- 让jquery easyui datagrid列支持绑定嵌套对象
嵌套对象是指返回的json数据,是对象的某个属性自带有属性.而我们恰恰又需要这个属性,默认情况下easyui的datagrid是不支持绑定嵌套对象的.比如:datagrid的field属性只能为fie ...
- wpf 中DataGrid 控件的样式设置及使用
本次要实现的效果为: 这个DataGrid需要绑定一个集合对象,所以要先定义一个Experience类,包含三个字段 /// <summary> /// 定义工作经历类 /// </ ...
- NPOI导出WPF DataGrid控件显示数据
最近做个项目,需要导出DataGrid显示的数据,中间遇到了不少的坑,在此纪录一下,方便以后查看,也希望能给用到的人,一点帮助. 导出DataGrid显示的数据,并不是导出DataGrid的Items ...
- wpf研究之道-datagrid控件(1)
"想要说些什么 又不知从何说起",每当想要写一些关于wpf的文章,总是沉思良久,怕自己写不好.今天我想要说的是wpf中datagrid控件.我们先来看看它在整个类的层次结构: ...
随机推荐
- python爬虫-抓取acg12动漫壁纸排行设置为桌面壁纸
ACG-wallpaper 初学python,之前想抓取P站的一些图片来着,然后发现acg12这里有专门的壁纸榜单,就写了个抓取壁纸作为mac桌面壁纸玩玩. 功能:抓取acg12壁纸榜单的动漫壁纸,并 ...
- 数据库学习任务四:数据读取器对象SqlDataReader、数据适配器对象SqlDataAdapter、数据集对象DataSet
数据库应用程序的开发流程一般主要分为以下几个步骤: 创建数据库 使用Connection对象连接数据库 使用Command对象对数据源执行SQL命令并返回数据 使用DataReader和DataSet ...
- vSphere笔记01~02
Vmware vsphere 虚拟化 云和大数据的底层!!!! 分类 1.开源:openstack:Linux:难(无图形化) nosqleasystack公司 2.企业版本:vsphere sdn! ...
- Web云笔记--CSS
CSS CSS CSS Web自学第二阶段之CSS 参考资料:<Head First HTML&CSS>(中文第二版)(美国)弗里昂ISBN:9787508356464 中国电力出 ...
- 201521123065《java程序设计》第8周学习总结
1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 1.2 选做:收集你认为有用的代码片段 1.Map通过get(key)来获取值: 2.HashMap和Hash ...
- 201521123094 《Java程序设计》第1周学习总结
1. 本周学习总结 ① Java根据应用领域分为三大平台:Java SE.Java EE.Java ME.Java SE平台,作为各大平台的基础,它分成JVM/JRE/JDK/Java语言四个主要部分 ...
- [BT5]信息收集1-2 Dnsmap
0.工具介绍 dnsmap is mainly meant to be used by pentesters during the information gathering/enumeration ...
- 201521123077 《Java程序设计》第14周学习总结
1. 本周学习总结 1.1以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 2. 书面作业 1. MySQL数据库基本操作 -参考:实验任务书-题目1 建立数据库,将自己的姓名.学号作为一条 ...
- java课程设计---计算器(201521123020 邱伟达)
1.团队课程设计博客链接 http://www.cnblogs.com/br0823/p/7064407.html 2.个人负责模板或任务说明 1.初始化按键 2.实现加减乘除开方乘方等运算 3.每个 ...
- 笔记1 linux 多线程 互斥锁
//mutex lock #include<stdio.h> #include<unistd.h> #include<pthread.h> struct test ...