We are using UltraGrid, and on it we have applied some styling from .isl file. With that we have set TextHAlign="Left". But in the form we want to use TextHAlign="Center" for one column. We are achieving it by using below code in IntializeRow(object sender, InitializeRowEventArgs e) event. But once we mouse hover on this Cell, the Aligment is set to Left.
e.Row.Cells["MyColumn"].Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
Please suggest the way how can we do it.
Screenshot:
Hello Narendra,
Thank you for posting to Infragistics Community!
I have been looking into your question and created a small sample with an UltraGrid of version 19.2 of Ultimate UI for WinForms as stated in the details of this case. The project loads an Infragistics Style File, containing a style, setting the GridCell role’s Normal state textHAlign property to “Left”. Then, as described by you, one of the columns’ TextHAlign is set n the InitializeRow event to HAlign.Center. However, I am only assuming that the style file is targeting the GridCell role. If this is not the case, please provide more details on how this is achieved.
On my side, everything works as expected and the overwritten alignment is persisted on hover. As the isolated sample shows the described features working correctly, this indicates that the issue is most probably local to your own project. Currently, I cannot tell for sure what may be causing this in your app, however, please make sure that the style file is not setting the alignment for the “HotTrakced” state of the GridCell as well.
In conclusion, please test the below attached sample on your side and let me know how it behaves.
Best regards,Bozhidara PachilovaAssociate Software Developer
0160.UGCellAlignment.zip
We are using below style in the .isl file:
<styles> <style role="GridCell" borderStyle="Solid"> <states> <state name="Normal" backColor="Transparent" foreColor="Black" borderColor="83, 83, 83" fontName="Segoe UI" textHAlign="Left" textVAlign="Center" borderAlpha="Opaque" fontSize="9" backGradientStyle="None" borderColor3DBase="Black" backHatchStyle="None" borderColor2="DarkGray" /> <state name="Selected" backColor="178, 178, 178" foreColor="Black" textHAlign="Left" textVAlign="Center" backGradientStyle="None" backHatchStyle="None" /> <state name="HotTracked" textHAlign="Left" textVAlign="Center"/> <state name="Active" backColor="178, 178, 178" foreColor="Black" borderColor="83, 83, 83" textHAlign="Left" textVAlign="Center" borderAlpha="Opaque" backGradientStyle="None" borderColor3DBase="Black" backHatchStyle="None" borderColor2="DarkGray" /> <state name="EditMode" backColor="178, 178, 178" fontName="Segoe UI" textHAlign="Left" textVAlign="Center" fontSize="9" backGradientStyle="None" backHatchStyle="None" /> <state name="ReadOnly" fontName="Segoe UI" textHAlign="Left" textVAlign="Center" fontSize="9" /> </states> </style> <style role="GridRow"> <states> <state name="Normal" textHAlign="Left" textVAlign="Center" /> <state name="AlternateItem" backColor="203, 214, 224" textHAlign="Left" textVAlign="Center" backGradientStyle="None" backHatchStyle="None" /> </states> </style> </styles>
We can't remove HotTracked property, because it's overriding property application wide. We need this in a specific form.