Display images in datagrid with Compact Framework

Is it possible to display an image in a datagrid cell? I am currently working with a compact 3.5 framework.

any tips on this?

+3
source share
5 answers

Like other posters, you commented, you need to collapse your own. Fortunately, this is not too complicated.

In my application, I need a way to draw a 16x16 icon in a specific column. I created a new class that inherits from DataGridColumnStyle, which makes it easy to apply to DataGridthrough an object DataGridTableStyle.

class DataGridIconColumn : DataGridColumnStyle {

public Icon ColumnIcon {
    get;
    set;
}

protected override void Paint( Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight ) {

    // Fill in background color
    g.FillRectangle( backBrush, bounds );

    // Draw the appropriate icon
    if (this.ColumnIcon != null) {
        g.DrawIcon( this.ColumnIcon, bounds.X, bounds.Y );
    }
  }
}

, ColumnIcon, , .

, DataGrid, :

DataGridTableStyle ts = new DataGridTableStyle();

DataGridIconColumn dgic = new DataGridIconColumn();
dgic.ColumnIcon = Properties.Resources.MyIcon;
dgic.MappingName = "<your_column_name>";
dgic.HeaderText = "<your_column_header>";

ts.GridColumnStyles.Add(dgic);

this.myDataGrid.TableStyles.Add( ts );

DataGridTableStyle - DataGrid. , .

+9

, , , , .

CF - .

+1

, , , : .

+1

, Resco SmartGrid.

0
0

Source: https://habr.com/ru/post/1710066/


All Articles