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

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)