I would like to create the effect shown below (Column2 right edge ... thick border) is it possible?
That works! thank you! Good for study too...
Hello Jeff,
We have some technical issues and the zip could not be attached. I am sending you the code you need:
public partial class Form1 : Form, IUIElementDrawFilter { public Form1() { InitializeComponent(); DataTable tb = new DataTable();
tb.Columns.Add("Column1"); tb.Columns.Add("Column2"); tb.Columns.Add("Column3"); tb.Columns.Add("Column4"); tb.Columns.Add("Column5");
BindingSource source = new BindingSource(); source.DataSource = tb;
this.ultraGrid1.DataSource = source;
for (int i = 0; i < 10; i++) { this.ultraGrid1.DisplayLayout.Bands[0].AddNew(); }
}
private void Form1_Load(object sender, EventArgs e) { this.ultraGrid1.DrawFilter = this; }
public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { CellUIElement cell = drawParams.Element as CellUIElement;
if (cell != null && cell.Column.ToString().Equals("Column2")) { Pen pen = drawParams.GetPen(DrawCache.PenType.Solid, Color.Red); pen.Width = 2; Rectangle r = new Rectangle(drawParams.Element.ChildElements[0].Rect.Location, new Size(drawParams.Element.Rect.Width - ((int)pen.Width + 2), drawParams.Element.ChildElements[0].Rect.Height) ); drawParams.Element.ChildElements[0].Rect = r; drawParams.Graphics.DrawLine(pen, new Point(cell.Rect.Right-2, cell.Rect.Location.Y - 1), new Point(cell.Rect.Right-2, cell.Rect.Bottom + 1));
return true; }
return false; }
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is CellUIElement) return Infragistics.Win.DrawPhase.BeforeDrawBorders;
return DrawPhase.None; }
Please let me know if you have any further questions.
... there is no attached zip.
In order to make a thick border between columns you could use the DrawFilter, in order to draw line border separator at the right side of a particular column , for more information please review following link:
http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/html/Win_Draw_Filter.html
I’ve implemented this suggestion in a simple sample, and you could run and evaluate it, please see attached zip.
Please let me know if you have any further questions