I have a custom cell element within a RadGridView. The custom cell is a RadGridView as well. I would like to show tooltips on some of the cells in the inner RadGridView. I am able to do this successfully by setting the cell's tooltiptext property in the Cell_formatting event, however, I need the tooltip to show for longer and I also need to format it. So, I tried creating an event handler for the ToolTipTextNeeded event and displaying a Windows.Forms tooltip there, but the event is not being raised at all. Please see my code below. If anyone can point out what I'm doing wrong, I'd really appreciate it.
Imports
Telerik.WinControls.UI
Public
Class
ClaimAdjustmentsCellElement
Inherits
GridDataCellElement
Public
Sub
New
(
ByVal
column
As
GridViewColumn,
ByVal
row
As
GridRowElement)
MyBase
.
New
(column, row)
End
Sub
Private
_radGridView
As
RadGridView
Private
tip
As
ToolTip =
New
ToolTip
With
{.BackColor = Color.AliceBlue, .ToolTipIcon = ToolTipIcon.Info, .InitialDelay = 500, .ShowAlways =
True
}
Protected
Overrides
Sub
CreateChildElements()
MyBase
.CreateChildElements()
_radGridView =
New
RadGridView()
With
_radGridView
.Dock = DockStyle.Fill
.
ReadOnly
=
True
.ShowFilteringRow =
False
.ShowGroupPanel =
False
.ShowColumnHeaders =
True
.ShowRowHeaderColumn =
False
.ShowNoDataText =
False
.AutoScroll =
True
.AutoSizeRows =
True
.SelectionMode = GridViewSelectionMode.CellSelect
.AutoGenerateColumns =
False
.ShowItemToolTips =
True
End
With
Dim
GroupCodeColumn
As
New
GridViewTextBoxColumn(
"Group.Code"
)
With
{.HeaderText =
"GC"
, .Width = 25}
Dim
ReasonColumn
As
New
GridViewTextBoxColumn(
"Reason.Code"
)
With
{.HeaderText =
"RSN"
, .Width = 35}
Dim
AmountColumn
As
New
GridViewDecimalColumn(
"Amt"
)
With
{.HeaderText =
"AMT"
, .FormatString =
"{0:c}"
, .Width = 75}
Dim
IsDenialColumn
As
New
GridViewCheckBoxColumn(
"Reason.IsDenial"
)
With
{.HeaderText =
"Denial"
, .Width = 65}
_radGridView.Columns.AddRange(GroupCodeColumn, ReasonColumn, DescrColumn, AmountColumn, IsDenialColumn)
AddHandler
_radGridView.CellFormatting,
AddressOf
_radGridView_CellFormatting
AddHandler
_radGridView.ToolTipTextNeeded,
AddressOf
_radGridView_TooltipTextNeeded
Me
.Children.Add(_radGridView.GridViewElement)
End
Sub
Protected
Overrides
Sub
SetContentCore(value
As
Object
)
If
value IsNot
Nothing
AndAlso
(
Not
value.Equals(DBNull.Value))
Then
_radGridView.DataSource = value
End
If
End
Sub
Private
Sub
_radGridView_CellFormatting(sender
As
Object
, e
As
CellFormattingEventArgs)
'e.CellElement.ToolTipText = ""
e.CellElement.DrawFill =
False
If
e.CellElement.IsSelected
Then
e.CellElement.DrawBorder =
False
Else
e.CellElement.DrawBorder =
True
End
If
'Dim oClaimAdj As ClaimAdjustment = TryCast(e.Row.DataBoundItem, ClaimAdjustment)
'Select Case e.Column.Name
' Case "Group.Code"
' If oClaimAdj IsNot Nothing AndAlso oClaimAdj.Group IsNot Nothing Then
' e.CellElement.ToolTipText = oClaimAdj.Group.Description
' End If
' Case "Reason.Code"
' If oClaimAdj IsNot Nothing AndAlso oClaimAdj.Reason IsNot Nothing Then
' e.CellElement.ToolTipText = oClaimAdj.Reason.Description
' End If
'End Select
End
Sub
Protected
Overrides
ReadOnly
Property
ThemeEffectiveType
As
System.Type
Get
Return
GetType
(GridDataCellElement)
End
Get
End
Property
Public
Overrides
Function
IsCompatible(data
As
Telerik.WinControls.UI.GridViewColumn, context
As
Object
)
As
Boolean
Return
TypeOf
(data)
Is
ClaimAdjustmentColumn
AndAlso
TypeOf
(context)
Is
GridDataRowElement
End
Function
Private
Sub
_radGridView_TooltipTextNeeded(sender
As
Object
, e
As
Telerik.WinControls.ToolTipTextNeededEventArgs)
Try
Dim
cell
As
GridDataCellElement = TryCast(sender, GridDataCellElement)
If
cell IsNot
Nothing
And
tip IsNot
Nothing
Then
Dim
oClaimAdj
As
ClaimAdjustment = TryCast(cell.RowElement.Data.DataBoundItem, ClaimAdjustment)
Dim
tipText
As
String
=
""
Select
Case
cell.ColumnInfo.FieldName
Case
"Group.Code"
If
oClaimAdj IsNot
Nothing
AndAlso
oClaimAdj.Group IsNot
Nothing
Then
tipText = oClaimAdj.Group.Description
End
If
Case
"Reason.Code"
If
oClaimAdj IsNot
Nothing
AndAlso
oClaimAdj.Reason IsNot
Nothing
Then
tipText = oClaimAdj.Reason.Description
End
If
End
Select
If
Not
String
.IsNullOrEmpty(tipText)
Then
With
tip
.Active =
False
.AutoPopDelay = 30000
.SetToolTip(_radGridView, tipText)
.Active =
True
End
With
End
If
End
If
Catch
ex
As
Exception
throw
End
Try
End
Sub
End
Class