Column border lines/background color

Hi,

how is it possible to set thicker border lines for a complete column and how to set background color for a complete column?
Is it even possible to set the color of the border lines?

Regards
Michael

3 Replies

SS Suhasini  Suresh Syncfusion Team March 29, 2018 04:14 PM UTC

Hi Michael, 
 
Thanks for contacting Syncfusion Support. 
 
We checked your query. You can achieve your requirement of setting the background color, border color and border thickness by using the template column. 
 
Please find the code snippet below to achieve your requirement. 
// MyViewController.cs 
GridTextColumn customerIdColumn = new GridTextColumn(); 
customerIdColumn.UserCellType = typeof(CustomCell); 
customerIdColumn.MappingName = "CustomerID"; 
dataGrid.Columns.Add(customerIdColumn); 
dataGrid.GridStyle = new GridStyle(); 
 
// CustomCell.cs 
 
public override void LayoutSubviews() 
{ 
    base.LayoutSubviews(); 
    // Set the background color of the column . 
    this.BackgroundColor = UIColor.Yellow; 
    this.label.Frame = new CGRect(10, Bounds.Top, Bounds.Width, Bounds.Height); 
    this.label.Text = DataColumn.CellValue.ToString(); 
} 
 
 
public override void Draw(CGRect rect) 
{ 
    base.Draw(rect); 
    var context = UIGraphics.GetCurrentContext(); 
    // Set the border thickness of the column. 
    context.SetLineWidth(3f); 
    // Set the border color for the column. 
    UIColor.Red.SetStroke(); 
    var path = new CGPath(); 
    path.AddLines(new CGPoint[] { new CGPoint(Bounds.Left, Bounds.Top), new CGPoint((Bounds.Left), Bounds.Bottom) }); 
    path.AddLines(new CGPoint[] { new CGPoint(Bounds.Right, Bounds.Top), new CGPoint(Bounds.Right, Bounds.Bottom) }); 
    path.AddLines(new CGPoint[] { new CGPoint(Bounds.Left, Bounds.Bottom), new CGPoint((Bounds.Right), Bounds.Bottom) }); 
    path.CloseSubpath(); 
    context.AddPath(path); 
    context.DrawPath(CGPathDrawingMode.FillStroke); 
    path = null; 
    context = null; 
} 
 
// GridStyle.cs 
 
public class GridStyle : DataGridStyle 
{ 
    public override GridLinesVisibility GetGridLinesVisibility() 
    { 
       return GridLinesVisibility.Both; 
    } 
} 
 
 
We have prepared a sample to achieve your requirement, you can download the same from the below link. 
 
Regards, 
Suhasini  
 



MI Michael March 31, 2018 08:16 AM UTC

Hi Suhasini,

thanks that is exactly what i was looking for!

Regards
Michael


SS Suhasini  Suresh Syncfusion Team April 2, 2018 04:12 AM UTC

Hi Michael,  
  
Thanks for your update. Let us know if you need any further assistance. 
 
Regards, 
Suhasini  


Loader.
Up arrow icon