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))); }
As a test, try commenting out that line of code and see if it works. If so, then that would indicate that the Style Library is explicitly setting the BorderStyle on the cell. So you will either need to change the Style Library to use rounded corners, or else not set the BorderStyle in the Style Library at all. That can get a little tricky since I think the BorderStyle could be set on a variety or different UI Roles.
So I recommend first confirming that it is, in fact, the StyleLibrary that is causing the borders not to change. And if you have trouble figuring out how to get it to work from there, perhaps you could post your style library file here and we can check it out and see if we can figure out how to modify it to get what you want.
Ok Mike, thank you very much for those explanations.I will go into all of this and see what I can do..Best regards
Hi Mike,
Hi,
The ComponentStyle you listed here is not important. That's the grid's ComponentRole, but if there's a header style applied, it would be a UIRole, so it would be a style tag or maybe a resource.
I created a small sample project with a grid and I set the BorderStyleRow and BorderStyleCell like you doing and I can see the rounded corners. Then I loaded your style library and they go away. So the style library is definately overriding the borders.
So I opened up your style library and started resetting roles to see which one is causing the borders to be applied. It looks like it the GridCell UIRole's Border Style Property. It's set to None, so that's overriding the setting in the code of Rounded4Thick.
So what you need to do is open your your style library in AppStylist, and set that property to default:
Note that this will apply to all of the grid's in your application. So if you are using more than one grid, other grids might now show up with cell borders where they did not before. But you could always set those grid's BorderStyleCell to None in code.
Hi Mike,Thank you very much for your help, it works now!On the other hand, I would like to create rounded corners only on certain specific cells of the grid and not on the whole grid.Would that be possible ?
Thanks Mike,I will try to do according to your advice.I'll keep you posted.Best regards
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; } }
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
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.
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.