Home Forums WinForms controls Xceed Grid for WinForms Disappearing Background Image when selected… Reply To: Disappearing Background Image when selected…

Xceed Support
Member
Post count: 5658

The problem here is that you are using BACKGROUND image, image style, etc. The Grid is painting the selected “context” after and on top of it.

 

You need to create a CellViewerManager, and set ImageArea, ImageAlignment, ImageStyle and possibly ImageSize. If there is no ImageArea, the GetImageCore() method will never be called.

 

By setting those properties, GetImageCore will be called and will return the wanted image and everything should work fine, the selected “context” not being painted on top of it.

 

 

e.g.,

 

public class MyCellViewerManager : TextViewer

{

  public MyCellViewerManager()

  {

    this.ImageArea = ImageArea.Left;

    this.ImageAlignment = ViewerImageAlignment.MiddleLeft;

 

    this.ImageStyle = ImageStyle.Align;

  }

 

  protected override string GetTextCore( object value, CellTextFormatInfo formatInfo, GridElement gridElement )

  {

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

  }

 

 

  protected override Image GetImageCore( object value, CellImageFormatInfo formatInfo, GridElement gridElement )

  {

    return new Bitmap( @”D:\test.jpg” );

  }

}

Imported from legacy forums. Posted by CharlesB (had 852 views)