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)
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):

            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;
Besides this I do a few things of my own:

        private void initGrid()
            // set default mappings for viewers, managers, and format specifiers
            // create a default style sheet and apply it
            this.grList.ApplyStyleSheet( this.getDefaultStyleSheet( true ) );

Then I add rows as follows:

        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 );
            this.addRowEventHandlers( row );
            return row.Index;

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)