引用:Telerik(官 网:http://www.telerik.com/)是保加利亚的一个软件公司,专注于微软.Net平台的表示层与内容管理控件。我们提供高度稳定性和丰富性能的组件产品,并可应用在非常严格的环境中。现在拥有 Microsoft, HP, Alcoa, BP, Harper Collins, Siemens, T-Mobile, HJ Heinz和一些最主要的教育机构和很多政府机关等客户。

我在使用的版本是RadControls_for_Silverlight4_2011_1_0316,开发工具采用VS2010 +SQLServer2008R2进行测试学习

Grid是我们做系统必不可少的控件了,所以我准备从这个开始,为自己留下学习痕迹。

先是了解控件属性便于下一步学习,常用属性

RadGridView

常用属性

说明

DEMO名称

AutoGenerateColumns="False"

是否自动产生列

 

IsReadOnly="True"

IsReadOnly="{Binding IsChecked, Mode=TwoWay, ElementName=IsReadOnlyCheckBox}"

是否只读

Click Event

command

ShowGroupPanel="False"

是否显示分组面板(常用,一般情况下是不会用到这个的)

 

DataLoadMode="Asynchronous"

数据加载模式

 

RowIndicatorVisibility="Collapsed"

行指示

 

SelectionMode="Extended"

 

Command

CanUserDeleteRows="{Binding IsChecked, Mode=TwoWay, ElementName=CanUserDeleteRowsCheckBox}"

是否可删除行

Command

ScrollViewer.HorizontalScrollBarVisibility="Auto"

ScrollViewer.VerticalScrollBarVisibility="Auto"

横向竖向滚动条设定

 

IsFilteringAllowed="False"

列过滤查询是否可用

Enable/Disable

ShowColumnFooters="True"

是否显示列脚

Totals

ShowGroupFooters="True"

是否显示分组列脚

Totals

GridLinesVisibility=

Both

Horizontal

Vertical

网络线设置

gridlinevisiblity

GridViewDataColumn

属性

说明

DEMO名称

IsGroupable="False"

列是否加入分组

 

IsFilterable="False"

列是否可过滤查询

 

IsSortable="False"

列是否可排序

 

DataFormatString="{}{0:c2}"

DataFormatString="{}{0:d}"

列输入格式

 

GridViewDataColumn.FilteringControl :可自定义表头查询控件

1、产生自动编号-Row Number

· 自定义列与绑定列并存

XAML
<Grid>
<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding Customers}" AutoGeneratingColumn="RadGridView1_AutoGeneratingColumn">
<telerik:RadGridView.Columns>
<custom:MyColumn Header="#" Width="50" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
 

· 自动绑定后的列取消功能(如果取消的列较多,还是需要考虑用别的方法替代)

 private void RadGridView1_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
{
if (e.Column.UniqueName == "Order" || e.Column.UniqueName == "Product")
{
e.Cancel = true;
}
}

· 自定义列的处理

public class MyColumn : Telerik.Windows.Controls.GridViewColumn
{
public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
{
TextBlock textBlock = cell.Content as TextBlock; if (textBlock == null)
{
textBlock = new TextBlock();
} textBlock.Text = (this.DataControl.Items.IndexOf(dataItem) + 1).ToString(); return textBlock;
}
}

2、行、列、单元格只读设置

private void ChangeEnableStateColumn(bool isEnabled)
{
GridViewHeaderRow headerRow = RadGridView1.ChildrenOfType<GridViewHeaderRow>().FirstOrDefault();
if (headerRow != null)
{
GridViewCellBase cell = (from c in headerRow.Cells
where c.Column.UniqueName == "EmployeeID"
select c).FirstOrDefault();
if (cell != null)
{
cell.IsEnabled = isEnabled;
}
} foreach (object item in RadGridView1.Items)
{
GridViewRow row = RadGridView1.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow;
if (row != null)
{
GridViewCellBase cell = (from c in row.Cells
where c.Column.UniqueName == "EmployeeID"
select c).FirstOrDefault();
if (cell != null)
{
cell.IsEnabled = isEnabled;
}
}
}
} private void ChangeEnableStateCell(bool isEnabled)
{
if (RadGridView1.Items.Count > 0)
{
GridViewRow row = RadGridView1.ItemContainerGenerator.ContainerFromItem(RadGridView1.Items[0]) as GridViewRow;
if (row != null)
{
GridViewCellBase cell = (from c in row.Cells
where c.Column.UniqueName == "EmployeeID"
select c).FirstOrDefault();
if (cell != null)
{
cell.IsEnabled = isEnabled;
}
}
}
} private void ChangeEnableStateRow(bool isEnabled)
{
if (RadGridView1.Items.Count > 0)
{
GridViewRow row = RadGridView1.ItemContainerGenerator.ContainerFromItem(RadGridView1.Items[0]) as GridViewRow;
if (row != null)
{
row.IsEnabled = isEnabled;
}
}
}
XAML
<Grid>
<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding Customers}" AutoGeneratingColumn="RadGridView1_AutoGeneratingColumn">
<telerik:RadGridView.Columns>
<custom:MyColumn Header="#" Width="50" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>

3、设置网格线颜色

private void VerticalGridLinesColorPicker_SelectedColorChanged(object sender, EventArgs e)
{
RadGridView1.VerticalGridLinesBrush = new SolidColorBrush(VerticalGridLinesColorPicker.SelectedColor);
} private void HorizontalGridLinesColorPicker_SelectedColorChanged(object sender, EventArgs e)
{
RadGridView1.HorizontalGridLinesBrush = new SolidColorBrush(HorizontalGridLinesColorPicker.SelectedColor);
}

4、保存用户对网格的设置

DEMO中saveandload settings中的Radgridviewsetting.cs非常用用:)

引用地址:http://www.cnblogs.com/forrestsun/archive/2011/05/13/2045859.html

【转】RadControls for Silverlight(学习1-GridView)的更多相关文章

  1. ArcGIS API for Silverlight学习笔记

    ArcGIS API for Silverlight学习笔记(一):为什么要用Silverlight API(转) 你用上3G手机了吗?你可能会说,我就是喜欢用nokia1100,ABCDEFG跟我都 ...

  2. asp.net学习之GridView事件、GridViewRow对象

    原文:asp.net学习之GridView事件.GridViewRow对象 1. GridView控件的事件 GridView有很多事件,事件可以定制控件的外观或者行为.事件分为三类     1.1 ...

  3. asp.net学习之GridView七种字段

    原文:asp.net学习之GridView七种字段 asp.net中GridView绑定到数据源时,可以自动显示数据源的各个字段.只要设定其AutoGenerateColumns为TRUE即可.但这, ...

  4. Silverlight:telerik RadControls for Silverlight 主题使用心得

    默认情况下: telerik RadControls控件使用的是Office Black 主题,就算在App.xaml.cs里写上 StyleManager.ApplicationTheme = ne ...

  5. 【转】RadControls for Silverlight(学习2-RadDataPager)

    引用地址:http://www.cnblogs.com/forrestsun/archive/2011/05/15/2046894.html <Grid x:Name="LayoutR ...

  6. ArcGIS api fo silverlight学习三(利用ElementLayer实现鼠标悬浮弹出自定义窗体)

    接着上一节继续学习,本节主要是利用ElementLayer实现鼠标悬浮弹出自定义窗体 参考博文:http://www.cnblogs.com/luxiaoxun/p/3322218.html 一.新建 ...

  7. ArcGIS api fo silverlight学习二(silverlight加载GraphicsLayer)

    上一节学习了silverlight加载GeoServer发布的WMS地图,这一节学习一下加载GraphicsLayer 一.加载.png或jpg文件图标 1.在MainPage.xaml中添加资源配置 ...

  8. ArcGIS api fo silverlight学习一(silverlight加载GeoServer发布的WMS地图)

    最好的学习资料ArcGIS api fo silverlight官网:http://help.arcgis.com/en/webapi/silverlight/samples/start.htm 一. ...

  9. Silverlight学习(三)

    最近对WCFRIA+MVVM+Prism有了初步的认识,能够简单的实现一些数据库的交互.这节主要讲的是Silverlight通过domainservice和ado.net实体数据模型与数据库的交互.本 ...

随机推荐

  1. sublime-text3 3059基本配置

    1.下载安装官方版注册机语言包 参考安装: http://www.xiumu.org/note/sublime-text-3.shtml 2.插件 Package ControlConvertToUT ...

  2. PBOC金融IC卡,卡片与终端交互的13个步骤,简介-第三组

    七:终端风险管理-必选但包含可选步骤异常文件:终端检查应用主账号是否在异常文件列表(卡号黑名单)中.商户强制联机:商户可以将当前交易强制为联机处理.最低限额:控制交易当前交易金额或同一张卡片连续几笔交 ...

  3. java: Thread 和 runnable线程类

    java: Thread 和 runnable线程类 Java有2种实现线程的方法:Thread类,Runnable接口.(其实Thread本身就是Runnable的子类) Thread类,默认有ru ...

  4. SQL与Mongodb聚合的对应关系(举例说明)

    SQL中的聚合函数和Mongodb中的管道相互对应的关系: WHERE $match GROUP BY $group HAVING $match SELECT $project ORDER BY $s ...

  5. ORACLE RAISE

    ORACLE 出错信息的输出 偷懒的办法直接在Exception 后使用raise但是错误信息不是很完整使用RAISE_APPLICATION_ERROR(-20999, DBMS_UTILITY.f ...

  6. (转载)SQL— CONCAT(字符串连接函数)

    有的时候,我们有需要将由不同栏位获得的资料串连在一起.每一种资料库都有提供方法来达到这个目的: MySQL: CONCAT() Oracle: CONCAT(), || SQL Server: + C ...

  7. secureCRT远程登录工具的颜色配置(转载)

    另外,字体和编码设置(如果需要显示中文):Options->Session Options->Appearance->font(字体:幼圆,字形:常规,大小:小三号,字符集:中文GB ...

  8. ActiveReport 同一单元格内图片跟文字按条件显示

    ActiveReports支持提供Image控件来显示图片素材,Image控件的值可以为图像的二进制流,图像路径,或url等:而在很多情况下,图片是签名扫描文件,并不会一直有值.如果图片的值为空,则显 ...

  9. jeesite部署到Tomcat后,无法访问,cannot be resolved in either web.xml or the jar files deployed with this application

    HTTP Status 500 - /WEB-INF/views/modules/sys/sysLogin.jsp (line: 3, column: 0) The absolute uri: htt ...

  10. mybatis输出SQL

    1.导包 下载一个log4j-1.2.17.jar,放到WEB-INF的lib下,并加入build path 2.创建配置文件 在src下创建log4j.properties,填入以下内容: log4 ...