如何创建一个支持垂直导航的自定义GridControl?
作者:zhuhm 来源:本站原创 浏览:Loading...次 发布时间:2012-11-05 评论:0条
问题描述:如何创建一个支持垂直导航的自定义GridControl?
解决方法:
C#
using System; using System.Collections.Generic; using System.Linq; using DevExpress.XtraGrid; using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Registrator; using VerticalDataNavigator.Navigator; namespace VerticalDataNavigator { [System.ComponentModel.DesignerCategory("")] public class CustomGridControl : GridControl { protected override ControlNavigator CreateEmbeddedNavigator() { ExtendedDataNavigator nav = new ExtendedDataNavigator(this); nav.SizeChanged += OnEmbeddedNavigator_SizeChanged; return nav; } protected override void RegisterAvailableViewsCore(InfoCollection collection) { base.RegisterAvailableViewsCore(collection); collection.Add(new CustomGridViewInfoRegistrator()); } public NavigatorOrientation EmbeddedNavigatorOrientation { get { return (EmbeddedNavigator as ExtendedDataNavigator).NavigatorOrientation; } set { ExtendedDataNavigator customizableNavigator = EmbeddedNavigator as ExtendedDataNavigator; if (value != customizableNavigator.NavigatorOrientation) { customizableNavigator.NavigatorOrientation = value; Invalidate(); } } } } }
VB.NET
Imports Microsoft.VisualBasic Imports System Imports System.Collections.Generic Imports System.Linq Imports DevExpress.XtraGrid Imports DevExpress.XtraEditors Imports DevExpress.XtraGrid.Views.Base Imports DevExpress.XtraGrid.Registrator Imports VerticalDataNavigator.Navigator Namespace VerticalDataNavigator <System.ComponentModel.DesignerCategory("")> _ Public Class CustomGridControl Inherits GridControl Protected Overrides Function CreateEmbeddedNavigator() As ControlNavigator Dim nav As New ExtendedDataNavigator(Me) AddHandler nav.SizeChanged, AddressOf OnEmbeddedNavigator_SizeChanged Return nav End Function Protected Overrides Sub RegisterAvailableViewsCore(ByVal collection As InfoCollection) MyBase.RegisterAvailableViewsCore(collection) collection.Add(New CustomGridViewInfoRegistrator()) End Sub Public Property EmbeddedNavigatorOrientation() As NavigatorOrientation Get Return (TryCast(EmbeddedNavigator, ExtendedDataNavigator)).NavigatorOrientation End Get Set(ByVal value As NavigatorOrientation) Dim customizableNavigator As ExtendedDataNavigator = TryCast(EmbeddedNavigator, ExtendedDataNavigator) If value <> customizableNavigator.NavigatorOrientation Then customizableNavigator.NavigatorOrientation = value Invalidate() End If End Set End Property End Class End Namespace
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/Resources/FAQ-305.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/Resources/FAQ-305.html
关键字: Grid GridControl
评论列表
暂无评论
请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!
慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。
电话:400-700-1020
023-66090381
邮箱:sales@evget.com