AUTHOR: Dimitar Karamfilov
DATE POSTED: August 24, 2016
Problem The design time functionality of the gauge controls allows you to easily create the desired gauge. This is not the case when you need to use a gauge inside other control as element. In this case the best solution would be to first create and save the layout at design time and then just load it form the xml. Figure 1: The final Result. Solution 1. Create the layout at design time and save it as xml by using the smart tag (you can use any of the predefined templates as well). 2. Open the saved file and remove the main tag, only the items collection should remain. For example you can use the following xml:
<
Items
>
Telerik.WinControls.UI.Gauges.BulletGraphQualitativeBar
RangeEnd
=
"49"
BackColor2
"184, 197, 218"
BackColor
Padding
"0, 0, 0, 0"
Name
"bulletGraphQualitativeBar1"
DataBindings
DefaultDataSourceUpdateMode
"OnValidation"
/>
</
"74"
RangeStart
"50"
"210, 219, 232"
"bulletGraphQualitativeBar2"
"75"
"237, 240, 246"
"bulletGraphQualitativeBar3"
Telerik.WinControls.UI.Gauges.BulletGraphFeaturedMeasureBar
Offset
"11"
Width2
"10"
Width
"85"
AutoSize
"False"
Bounds
"0, 0, 280, 50"
"bulletGraphFeaturedMeasureBar1"
Telerik.WinControls.UI.Gauges.LinearGaugeNeedleIndicator
LineLenght
"30"
LocationPercentage
Thickness
"3"
Value
"80"
LenghtPercentage
"0"
"Black"
"linearGaugeNeedleIndicator1"
Telerik.WinControls.UI.Gauges.LinearGaugeLabels
"0, 0, 280, 40"
"linearGaugeLabels1"
class
CustomSummaryCell : GridSummaryCellElement
{
public
CustomSummaryCell(GridViewColumn col, GridRowElement row) :
base
(col, row)
{ }
RadLinearGaugeElement bullet1;
protected
override
void
CreateChildElements()
.CreateChildElements();
bullet1 =
new
RadLinearGaugeElement();
bullet1.Padding =
Padding(5,3,7,3);
using
(StreamReader sr =
StreamReader(@
"..\..\BulletDefault1.xml"
))
var ser =
ComponentXmlSerializer();
(XmlTextReader textReader =
XmlTextReader(sr))
ser.ReadObjectElement(textReader, bullet1);
}
this
.Children.Add(bullet1);
SetContent()
.SetContent();
((LinearGaugeNeedleIndicator )
.bullet1.Items[4]).Value = Convert.ToSingle(
.Value.ToString());
Friend
Class
CustomSummaryCell
Inherits
GridSummaryCellElement
Public
Sub
New
(
ByVal
col
As
GridViewColumn,
row
GridRowElement)
MyBase
.
End
Private
bullet1
RadLinearGaugeElement
Protected
Overrides
.CreateChildElements()
RadLinearGaugeElement()
Padding(5,3,7,3)
Using sr
StreamReader(
)
Dim
ser =
ComponentXmlSerializer()
Using textReader
XmlTextReader(sr)
ser.ReadObjectElement(textReader, bullet1)
Using
Me
.Children.Add(bullet1)
.SetContent()
CType
.bullet1.Items(4), LinearGaugeNeedleIndicator).Value = Convert.ToSingle(
.Value.ToString())
private
RadGridView1_CreateCell(
object
sender, GridViewCreateCellEventArgs e)
if
(e.CellType ==
typeof
(GridSummaryCellElement) && e.Column.Name ==
"Dosage"
e.CellElement =
CustomSummaryCell(e.Column, e.Row);
sender
Object
,
e
GridViewCreateCellEventArgs)
If
e.CellType
Is
GetType
(GridSummaryCellElement)
AndAlso
e.Column.Name =
Then
CustomSummaryCell(e.Column, e.Row)
You can download a complete example from the below link.
Resources Buy Try