User (Old forums)MemberAugust 25, 2003 at 12:22 pmPost count: 23064
I am attempting to build a series of cells in a data row and need to individually adjust the visibility and thickness of a cell’s border. However, I’m not having success. Here’s what I’m trying to do…
Dim drRow As DataRow
drRow = GridControl1.DataRows.AddNew()
drRow.Cells(0).Value = “Cell1”
drRow.Cells(0).Borders.Left = 0
. . .
However, the last line shown gives me an error. It states that the “Expression is a value and therefore cannot be the target of an assignment”. But, it appears that …Borders.left is a get/set property and should be able to be set in this method.
Can someone tell me what I’m doing incorrectly? Or has someone had a better method of performing Border manipulations?
Imported from legacy forums. Posted by JIpock (had 5078 views)Xceed SupportMemberAugust 25, 2003 at 1:04 pmPost count: 5658
The Borders property is readonly, that is why you cannot set it. What you will need to do is create a class that derives from the DataCell class and override the Borders property to return the value you want.
Of course, you will also need to create a custom DataRow class that derives from the DataRow class that will create your custom cells. You can assign your DataRow to the grid’s DataRowTemplate property to use it automatically.
You can find information (as well as templates) on how to create a class that derives from both the DataCell and DataRow class in the help file under <a href=”http://doc.xceedsoft.com/products/gridNet/doc/sources/extending.htm”>Advanced Concepts/Extending</a>.
I hope this helps!
Imported from legacy forums. Posted by Jenny [Xceed] (had 988 views)User (Old forums)MemberOctober 24, 2005 at 12:16 amPost count: 23064
I have managed to draw a single line, but what I am really after
is 2 lines
However the the following only shows 1 line.
Protected Overrides Sub PaintBorders(ByVal e As GridPaintEventArgs)
Dim blackPen As New Pen(Color.Red, 3)
Dim rect As Rectangle
rect = e.DisplayRectangle
e.Graphics.DrawLine(blackPen, rect.Left, rect.Bottom, rect.Right, rect.Bottom)
e.Graphics.DrawLine(blackPen, rect.Left, rect.Bottom – 5, rect.Right, rect.Bottom – 5)
Imported from legacy forums. Posted by Soong (had 340 views)User (Old forums)MemberOctober 24, 2005 at 1:59 amPost count: 23064
Instead of drawing a line at vertical coordinate rect.Bottom, try drawing at rect.Bottom – 1.
I’ve been having similar problems with drawing in general. I think rect.Bottom is just 1 pixel outside the drawing region.
Imported from legacy forums. Posted by Tommy (had 287 views)User (Old forums)MemberOctober 24, 2005 at 5:37 amPost count: 23064
I think the PaintBorders event is just for borders
I have tried the paint event but without success.
Imported from legacy forums. Posted by Soong (had 4489 views)Xceed SupportMemberJune 28, 2010 at 9:20 pmPost count: 5658
I know this is a old thread, but I have found it useful and can shed some light on how to make a double line.
I have used an extended DataRow only, rather than an extended DataCell in conjunction with an extended DataRow. This is because I have been drawing horizontal borders at the top and bottom of some whole rows rather than left and right vertical borders on individual cells. But I expect the same principal applies.
I have found that overriding PaintBorders imposes two restrictions on the kind of lines that can be drawn. First, as Soong has mentioned, it is only possible to draw lines exactly on the borders. So double lines, i.e. with the second line just inside the cell relative to the line on the border. Secondly the width of the line is always one pixel, irrespective of the Width of the Pen with which the line is drawn.
The circumvention is to override PaintForeground instead of PaintBorders. I should think overriding PaintBackground would work too, but I have not tried that. By overriding PaintForeground, I can draw a nice thick line on the row border. (I find that a single-pixel black line does not stand out enough compared with the standard grid lines.) And I can draw a second line just inside the cell. Presumably it would be possible to have stripes going all the way down or across!
Imported from legacy forums. Posted by Simon (had 1592 views)
- You must be logged in to reply to this topic.