Dim gbe As New GridGroupByExpression("Grupa Group By Grupa")
gv_dodatkowe.MasterGridViewTemplate.GroupByExpressions.Add(gbe)
void _grid_CellFormatting(object sender, CellFormattingEventArgs e) |
{ |
if (e.CellElement.ColumnInfo is GridViewDataColumn && !(e.CellElement.RowElement is GridTableHeaderRowElement)) |
{ |
GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo; |
if (column.FieldName == "Minutes") |
{ |
int minutes = (int)e.CellElement.RowInfo.Cells["Minutes"].Value; |
TimeSpan ts = TimeSpan.FromMinutes(minutes); |
e.CellElement.Text = string.Format("{0:00}:{1:00}", ts.Hours, ts.Minutes); |
void _grid_CellFormatting(object sender, CellFormattingEventArgs e) |
{ |
if (e.CellElement.ColumnInfo is GridViewDataColumn && (!(e.CellElement.RowInfo is GridViewFilteringRowInfo)) && |
(!(e.CellElement.RowElement is GridTableHeaderRowElement))) |
{ |
GridViewDataColumn column = (GridViewDataColumn)e.CellElement.ColumnInfo; |
if (column.FieldName == "Minutes") |
{ |
if(e.CellElement.RowInfo.Cells["Minutes"].Value!=null) |
{ |
int minutes = (int)e.CellElement.RowInfo.Cells["Minutes"].Value; |
TimeSpan ts = TimeSpan.FromMinutes(minutes); |
I have an image cell where the image is added conditionally using CellFormatting:
Private Sub RadGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
Try
If e.CellElement.ColumnIndex = 1 Then
If CType(e.CellElement.RowInfo.Cells("type").Value = 0, Decimal) Then
e.CellElement.Image = Me.ImageList1.Images(0)
ElseIf CType(e.CellElement.RowInfo.Cells("type").Value = 1, Decimal) Then
e.CellElement.Image = Me.ImageList1.Images(1)
ElseIf CType(e.CellElement.RowInfo.Cells("type").Value = 2, Decimal) Then
e.CellElement.Image = Me.ImageList1.Images(2)
ElseIf CType(e.CellElement.RowInfo.Cells("type").Value = 3, Decimal) Then
e.CellElement.Image = Me.ImageList1.Images(3)
Else
e.CellElement.Image = Me.ImageList1.Images(3)
End If
End If
e.CellElement.DrawFill = True
If Not IsDBNull(e.CellElement.RowInfo.Cells("Status").Value) Then
e.CellElement.DrawFill = True
Select Case (e.CellElement.RowInfo.Cells("Status").Value)
Case 23
e.CellElement.BackColor = Color.Pink
Case 24
e.CellElement.BackColor = Color.Chartreuse
Case 25
e.CellElement.BackColor = Color.Yellow
Case 26
e.CellElement.BackColor = Color.SkyBlue
Case 27
e.CellElement.BackColor = Color.LightCyan
Case 28
e.CellElement.BackColor = Color.Crimson
Case 29
e.CellElement.BackColor = Color.Blue
Case 30
e.CellElement.BackColor = Color.Red
Case Else
End Select
Else
e.CellElement.BackColor = Color.WhiteSmoke
End If
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
This colours the whole row I only want the background behind the image to have the colour applied how do I do this?
Regards
Joe
private void SetupForm() |
{ |
try |
{ |
// Add the events |
this.radGridViewExceptions.ViewCellFormatting += new Telerik.WinControls.UI.CellFormattingEventHandler(radGridViewExceptions_ViewCellFormatting); |
this.radGridViewExceptions.DataSource = m_objExceptions.GetLast30DaysExceptions(); |
// Wrapping text only seems to work correctly if this is not commented out // and I do not set the column widths below // this.radGridViewExceptions.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; |
this.radGridViewExceptions.MasterGridViewTemplate.AllowColumnReorder = false; |
this.radGridViewExceptions.MasterGridViewTemplate.AllowColumnResize = false; |
this.radGridViewExceptions.AutoSizeRows = true; |
// Format the columns |
foreach (GridViewColumn column in radGridViewExceptions.Columns) |
{ |
switch (column.HeaderText) |
{ |
case "When_Occured": |
case "Description": |
column.Width = 200; |
break; |
case "App_Assembly": |
column.Width = 120; |
break; |
case "App_Assembly_Version": |
column.Width = 150; |
break; |
default: |
column.Width = 100; |
break; |
} |
column.WrapText = true; //radCheckBoxShowFullText.Checked; |
} |
m_bFormLoaded = true; |
} |
catch (Exception ex) |
{ |
ShowException(ex); |
m_bFormLoaded = false; |
} |
} |