Home › Forums › WinForms controls › Xceed Grid for WinForms › rowselector
-
AuthorPosts
-
#16444 |
Hi,
I am setting up my Datarowtemplate to have a numbered row selector (see below).
The trouble is I loose the triangle pointer that shows the current row.
Is it possible to keep the pointer and the numbers?vb.net please
Dim dr As DataRow
dr = New DataRow(New NumberedRowSelector())
dr.AutoHeightMode = AutoHeightMode.None
dr.MaxHeight = 17
dr.MinHeight = 17
xg.DataRowTemplate = dr
–then load grid—class
Imports System.Drawing
Imports Xceed.GridPublic Class NumberedRowSelector
Inherits RowSelector‘ Initializes a new instance of the NumberedRowSelector class.
Public Sub New()
End Sub‘ Initializes a new instance of the NumberedRowSelector class specifying the
‘ type of index to display.
Public Sub New(ByVal IndexType As IndexTypeEnum)
m_indexType = IndexType
End Sub‘ Initializes a new instance of the NumberedRowSelector class specifying the
‘ template that will be used to create other selectors.
Protected Sub New(ByVal template As NumberedRowSelector, ByVal parentRow As Row)
MyBase.New(template, parentRow)
m_indexType = template.m_indexTypeEnd Sub
‘ Creates a clone of the NumberedRowSelector.
Protected Overrides Function CreateInstance(ByVal parentRow As Row) As RowSelector
Return New NumberedRowSelector(Me, parentRow)
End Function‘ Paints the foreground of the NumberedRowSelector.
Protected Overrides Sub PaintForeground(ByVal e As GridPaintEventArgs)‘ Only paint the datarows
If TypeOf (Me.Row) Is DataRow Then
Dim dataRow As DataRow = Me.Row
Dim number As Integer = 0
‘Select Case Me.IndexType
‘ Case IndexTypeEnum.DataSourceIndex
‘ number = dataRow.Index‘ Case IndexTypeEnum.GroupIndex
‘ number = dataRow.ParentGroup.GetSortedDataRows(False).IndexOf(dataRow)‘End Select
‘number = dataRow.Index + 1
number = dataRow.ParentGrid.GetSortedDataRows(True).IndexOf(dataRow) + 1‘ It is recommended to use the color returned from GetDisplayForeColor()
‘ rather than the ForeColor property directly.
Dim brush As New SolidBrush(Me.GetDisplayForeColor())
e.Graphics.DrawString(number.ToString(), Me.Font, brush, RectangleF.op_Implicit(Me.ClientRectangle))
brush.Dispose()
Else
‘ Not a DataRow, so let the base class paint itself.
MyBase.PaintForeground(e)
End If
End Sub‘ Gets or sets the type of index to display in the RowSelector.
‘
‘ The “ApplyToDesigner” attribute allows modifications to the
‘ property to be reflected by the WYSIWYG designer.
<ApplyToDesigner(True)> _
Public Property IndexType() As IndexTypeEnum
Get
Return m_indexType
End Get
Set(ByVal Value As IndexTypeEnum)
m_indexType = Value
End Set
End PropertyPrivate m_indexType As IndexTypeEnum = IndexTypeEnum.GroupIndex
End Class
Public Enum IndexTypeEnum
DataSourceIndex = 0
GroupIndex = 1
End EnumThanks in advance.
Imported from legacy forums. Posted by troy@querytool.com (had 806 views)
Well, you could simply call base in PaintForeground when the row is the CurrentRow (e.g. Me.Row.IsCurrent). This way it will even paint the icon when the row is being edited.
Imported from legacy forums. Posted by André (had 224 views)
Simply great. Thanks.
Imported from legacy forums. Posted by troy@querytool.com (had 985 views)
-
AuthorPosts
- You must be logged in to reply to this topic.