XAML:
<telerik:RadGridView FrozenColumnCount="1" CanUserFreezeColumns="False" IsReadOnly="False" AutoGenerateColumns="False" GridColumn="0" GridRow="0" Name="radGridView1" DataLoadMode="Asynchronous" Height="Auto" >
</telerik:RadGridView>
注意:必须FrozenColumnCount="1" CanUserFreezeColumns="False",这样做以防止出现横向滚动条的时候,获取的列发生变化。
CS:
GridViewDataColumn gv0 = new GridViewDataColumn();
gv0Header = "系统批次号";
gv0IsReadOnly = true;
Binding MyBinding0 = new Binding();
MyBinding0Path = new PropertyPath("系统批次号");
MyBinding0Mode = BindingModeOneWay;
gv0DataMemberBinding = MyBinding0;
gv0MinWidth = 00001;//不能为0,也不能超过4位小数,不然都抓取不到
gv0Width = 00001;//不能为0,也不能超过4位小数,不然都抓取不到
gv0IsGroupable = false;//防止分组
gv0IsResizable = false;//防止鼠标改变列宽
gv0IsSortable = false;//防止排序
gv0IsFilterable = false;//防止过滤
thisradGridView1ColumnsAdd(gv0);
获取办法:
GridViewRow row = thisradGridView1ItemContainerGeneratorContainerFromItem(radGridView1SelectedItem) as GridViewRow;
if (row != null)
{
var cell = rowCells[0] as GridViewCell;//我需要获取的列的Index是0,所以这里是Cells[0]
if (cell != null)
{
MessageBoxShow(cellValueToString());//Show出值
}
}
DataGridView的CelEndEdit事件可以满足你的要求,
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (eColumnIndex == 2)
{
try
{
double price = ConvertToDouble(dataGridView1Rows[eRowIndex]Cells[4]Value);
int count = ConvertToInt32(dataGridView1Rows[eRowIndex]Cells[2]Value);
double total = price count;
dataGridView1Rows[eRowIndex]Cells[7]Value = total;
}
catch
{
return;
}
}
}
/加载表格数据function loadData(params) { $(\\'#dg\\')datagrid({ url: \\'/admin/attractions/attractions\\', title: \\'景点列表\\', width: \\'100%\\', rownumbers: true, autoRowHeight: true, fitColumns: true,//列自适应 isField: \\'ID\\',//主键列的列
以上就是关于怎么获取DataGrid或者RadGridView单元格里的值全部的内容,包括:怎么获取DataGrid或者RadGridView单元格里的值、C# dataGridView中怎么样动态改变列的值、为什么DataGrid通过getChanges方法获取更改的数据总少一条等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)