Home Forums WinForms controls Xceed Grid for WinForms text in numeric field

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15258 |

    I have an Xceed grid that has two numeric columns as shown below.
    As you can in the first row and last row, I would like to display a text i.e. “less than 10” etc.
    Is there any way to do that?
    I would still want the fields to be numeric, and all numeric values editable. Is there any way to do that?

    Min Max
    —————————————
    less than 10
    10 20
    20 40
    greather than 60

    Thanks,

    Imported from legacy forums. Posted by userX (had 2800 views)

    User (Old forums)
    Member
    Post count: 23064

    I was able to do that using the obsolete ICellViewer by implementing the method PaintCellValue, i.e.

    public bool PaintCellValue(GridPaintEventArgs e, Cell cell)
    {
    e.Graphics.DrawString(“Less than”,cell.Font,Brushes.Black,e.ClientRectangle.X,e.ClientRectangle.Y );
    return true;
    }

    But when I try to do the same thing by inherting from the TextViewer i.e.

    protected override void SetControlValueCore(Cell cell)
    {
    Control.Text = “Or Greater”;
    }

    It doesnt work.

    Any help will be appreciated

    Imported from legacy forums. Posted by userX (had 286 views)

    User (Old forums)
    Member
    Post count: 23064

    You can to do something similar with the CellEditorManager.

    e.g.:

    class MyCellViewerManager : CellViewerManager
    {
    public MyCellViewerManager()
    : base()
    {
    }

    protected override string GetTextCore( object value, CellTextFormatInfo formatInfo, GridElement gridElement )
    {
    int cellValue = ( Int16 )value;

    if( cellValue < 10 )
    return “Less then 10”;

    if( cellValue > 60 )
    return “More then 60”;

    return base.GetTextCore( value, formatInfo, gridElement );
    }
    }

    In your code, to use the following class, simply do the following :

    gridControl1.Columns[ “NumColumn” ].CellViewerManager = new MyCellViewerManager();

    Imported from legacy forums. Posted by André (had 225 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks a lot, I was able to solve this

    Imported from legacy forums. Posted by userX (had 3847 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.