Home Forums WinForms controls Xceed Grid for WinForms Image display cut off in CellViewerManager

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

    I have a CellViewerManager subclass that I use for displaying a small image and a line of text. The class is small enough that I will provide it below:

    <code>

            class ImageTextViewer : CellViewerManager
            {
                private const int PADDING = 2;

                public ImageTextViewer() : base()
                {}

                protected override ImageArea DefaultImageArea
                {
                    get { return ImageArea.Left; }
                }

                protected override Xceed.UI.Margins DefaultImagePadding
                {
                    get { return new Xceed.UI.Margins( PADDING ); }
                }

                protected override Xceed.UI.Margins DefaultTextPadding
                {
                    get { return new Xceed.UI.Margins( PADDING ); }
                }

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

                      // code to retrieve image from underlying cell value

                       return image;
                }
            }

    </code>

     

    This works fine except my image, which is a standard icon size, 14 by 14 pixels, has a row of pixels sliced off at the top. This remains the case no matter what I do with the padding and the row height. If anyone can tell me what I’m doing wrong I would greatly appreciate it.

     

    Thanks,

    Aaron Haspel

    Imported from legacy forums. Posted by Aaron (had 2400 views)

    User (Old forums)
    Member
    Post count: 23064

    At this point, we do not reproduce this using your class.

    What is the DataType of the column on which you set the viewer?  Can you paste the code you use to set up the grid?

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

    User (Old forums)
    Member
    Post count: 23064

    Well Andre this gets a bit complicated since it occurs in my own subclassed version of your grid, but I will try to abstract the relevant parts.

    The DataType of the column is a custom object of my own that contains a list of other custom objects. That DataType has an overridden ToString() method that returns the text for the cell, and a getImage() method that returns the image. The cell is not editable so it has no CellEditorManager, only the CellViewerManager, whose code I have already posted. The grid setup code is as follows:

    So here’s the basic setup code for the grid (auto-generated by the Component Designer):

    <code>
                this.grList.AllowDrop = true;
                this.grList.DataRowTemplate = this.dataRowTemplate;
                this.grList.FixedHeaderRows.Add( this.groupByRow );
                this.grList.FixedHeaderRows.Add( this.columnManagerRow );
                this.grList.Location = new System.Drawing.Point( 0, 0 );
                this.grList.MaximumSize = new System.Drawing.Size( 2000, 1000 );
                this.grList.Name = “grList”;
                this.grList.ReadOnly = false;
                this.grList.ScrollBars = Xceed.Grid.GridScrollBars.Vertical;
                this.grList.ShowTreeLines = false;
                this.grList.ShowUnlinkedColumns = true;
                this.grList.SingleClickEdit = true;
                this.grList.Size = new System.Drawing.Size( 621, 277 );
                this.grList.TabIndex = 0;
                this.grList.MouseClick += new System.Windows.Forms.MouseEventHandler( this.grList_MouseClick );
                this.grList.MouseMove += new System.Windows.Forms.MouseEventHandler( this.grList_MouseMove );
                this.grList.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler( this.grList_MouseDoubleClick );
                this.grList.DragDrop += new System.Windows.Forms.DragEventHandler( this.grList_DragDrop );
                this.grList.CurrentRowChanged += new System.EventHandler( this.grList_CurrentRowChanged );
                this.grList.DragEnter += new System.Windows.Forms.DragEventHandler( this.grList_DragEnter );
                //
                // dataRowTemplate
                //
                this.dataRowTemplate.CanBeCurrent = true;
                this.dataRowTemplate.CanBeSelected = false;
                this.dataRowTemplate.Visible = true;
                //
                // groupByRow
                //
                this.groupByRow.Visible = false;
    </code>           
               
               
    Besides this I do a few things of my own:

    <code>
            private void initGrid()
            {
                // set default mappings for viewers, managers, and format specifiers
                this.setViewerMappings();
                this.setEditorMappings();
                this.setFormatSpecifiers();
                // create a default style sheet and apply it
                this.grList.ApplyStyleSheet( this.getDefaultStyleSheet( true ) );
            }
    </code>

    Then I add rows as follows:

    <code>
            private int addRow( IEnumerable plRowValues, DataRowList plRows )
            {
                DataRow row = plRows.AddNew();
                int index = row.Index;
                int i = 0;
                foreach( object val in plRowValues )
                {
                    object cellValue = formatValue( val, i );
                    Cell cell = row.Cells[ i ];
                    cell.Value = formatValue( val, i );
                    // override default CellViewerManager for the datatype if necessary, this is where the ImageTextViewer is assigned
                    this.setViewer( cell );
                    i++;
                }
                this.addRowEventHandlers( row );
                row.EndEdit();
                return row.Index;
            }
    </code>

    I hope this helps. I should also note that with a smaller image, using the same ImageTextViewer class, I do not have this problem.

    Best regards,
    Aaron Haspel

    Imported from legacy forums. Posted by Aaron (had 385 views)

    User (Old forums)
    Member
    Post count: 23064

    You do too many custom things that we don’t have access to to be able to identify the problem.  At this point, we would need a working sample demonstrating the issue, to be able to investigate this further.

    If you are entitle to support, you can send us an email at support@xceed.com, with a sample application and a link to this thread.

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

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