Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
910
How to get the value out of a Cell in C# and apply Cell Level Styles
posted

Hey Everyone

 Im trying to get the value out of a cell.

I want to apply Cell Level Styles based on the value in a cell.  I have bound a DataTable to the DataSource property of the DataGrid

I am using the InitializedRecord event, which gives me each record as it created in the grid.

However, I have search and searched and can not find out an easy way of viewing the data in the cells?

...

 On a side note, once I figure out how to examine the data in the cells, what would be the best way to apply cell level styles?

I need to do different text, and text formats and even as far as shading and background color changes.

 Thanks

DK

Parents
No Data
Reply
  • 4850
    Offline posted

    Hi DK,

    The best way to do this is to provide a style for the CellValuePresenter (or even for the Editor within the cvp). You can set it for an individual Field thru the Field.Settings.CellValuePresenterStyle property (or EditorStyle property). Then you can use a binding with a path of "Value" and relative source of 'Self' (if the property is being set directly on the CellValuePresenter) or "TemplatedParent" if the property is being set on an element with the ControlTemplate of the style. You then provide a custom converter, a class you write that implements the IValueConverter interface. e.g.

        <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=Value, Converter={StaticResource MyValueToBackgroundConverter}}">

    To see some additional examples of this approach check out the following thread http://forums.infragistics.com/forums/t/1679.aspx

    I hope this helps

Children