简体   繁体   中英

Changing color of Selected row of DataGrid by touch

I am new in smart device application development. I got very few options in DataGrid of Smart Device. Can anyone suggest me the correct event and solution to change Background color of selected row in DataGrid.

I've answered a similar question before for the DataGrid in the CompactFramework. Please see my answer in this question. Color whole row instead of column

Hope this helps. There's even an example project that I provided for download at the end of my answer.

In my example, I handle the paint for a DataGridColumn you can use that event to check if you are the currently selected row and paint whatever color you like.

protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
    {
        DataGridFormatCellEventArgs e = new DataGridFormatCellEventArgs(rowNum, source);
        e.ForeBrush = foreBrush;
        e.BackBrush = backBrush;
        OnSetCellFormat(e);
        base.Paint(g, bounds, source, rowNum, e.BackBrush, e.ForeBrush, alignToRight);
    }

Right there on base.Paint you can pass in different brushes etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM