Best regards
It might be that the border style is being overriden by something else. Are you loading a Style Library into your application? Look for "StyleManager.Load" in your code. Are you loading a layout into your grid that might be blowing away this setting? Look for LoadFromXml or LoadFromBinary or maybe just the Load method on the grid.DisplayLayout or e.Layout.
[EventSubscription(EventTopicNames.StyleChanged, ThreadOption.Publisher)] public void OnStyleChanged(object sender, ChangeStyleArgs eventArgs) { Infragistics.Win.AppStyling.StyleManager.Load(new MemoryStream(ShellApplication.ResourceManager.GetStyleFile(eventArgs.StyleLibrary))); }
There's no way to set the BorderStyle on a single cell. And borders in the grid are tricky because in most border styles, a cell only draws 1 or 2 of it's own borders and relies on the adjacent cells to draw the others.
In theory, if you have NO borders on the cells and you just want to draw rounded borders on some specific cells, you might be able to achieve something like this using a DrawFilter. But it depends on which cells you are talking about, what border style the other cells are using, and some other factors. It could be very tricky.
Thanks for the information, Mike.I also tried to do it with a DrawFilter but I did not find which method and which configuration should be used.Could you give me this information so that I can still try what it looks like?Thank you in advance.
It's really hard for me to guide you here without knowing:1) What criteria you are using to determine which cells will have a rounded borders2) What border style you are using for the other rows/cellsGenerally speaking, if you want to highlight certain cells in the grid, I recommend doing it using colors, rather than borders, because borders are very tricky and cells overlap.
Ok Mike,thanks for all your help.I will try and if I can do it, I will send you the code.
Best regardsChristian Pokorny
Hi Christian,
So this question has been kinda rolling around in the back of mind, and I think the best thing for you to do would be to do it backwards. That is... set BorderStyleCell to Rounded4Thick and then turn OFF the borders on the cells you DON'T want using the DrawFilter. I think you have to do it that way, because of BorderStyleCell on the Override is NOT set to Rounded4Thick, the grid won't know to leave space for that extra-thick border and it won't know not to overlap the cells.
So then all your DrawFilter has to do is handle the BeforeDrawBorders phase for cells and return true to prevent that cell from showing a border, or else return false to just let it draw the border. So the DrawFilter would look something like this. This DrawFilter looks for cells in the "Int32 1" or "Int32 2" column whose value is greater than 2 and returns false to let those cells go ahead and draw the rounded border. And it returns true for any other cell(s), so they draw no borders.
internal class RoundedBordersDrawFilter : IUIElementDrawFilter { public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { var cell = drawParams.Element.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (null != cell) { switch (cell.Column.Key) { case "Int32 1": case "Int32 2": var cellValue = (int)cell.Value; if (cellValue > 2) return false; break; } } return true; } public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is CellUIElementBase) return DrawPhase.BeforeDrawBorders; return DrawPhase.None; } }
Thanks Mike,I will try to do according to your advice.I'll keep you posted.Best regards