Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

PropertyEditor DrawToImage fails in windows xp but not in windows 7

Hi all,

I have a PropertyEditor hosted into a cell in datagridview. My problem was that when cell loses focus, this propertyeditor makes invisible and only is visible when entering in edit mode. I have searched for information and it is a normal behaviour of datagridview when hosting custom controls. So to solve this problem, I overrided the paint method:

 

 

protected override void Paint(
            Graphics graphics,
            Rectangle clipBounds,
            Rectangle cellBounds,
            int rowIndex,
            DataGridViewElementStates cellState,
            object value,
            object formattedValue,
            string errorText,
            DataGridViewCellStyle cellStyle,
            DataGridViewAdvancedBorderStyle advancedBorderStyle,
            DataGridViewPaintParts paintParts)
        {
            // Call the base class method to paint the default cell appearance.
            base.Paint(
                graphics,
                clipBounds,
                cellBounds,
                rowIndex,
                cellState,
                value,
                formattedValue,
                errorText,
                cellStyle,
                advancedBorderStyle,
                paintParts);
 
            PropertyEditor propertyEditor = (PropertyEditor)this.DataGridView.Rows[rowIndex].Cells[this.ColumnIndex].Value;
  
            Bitmap img = new Bitmap(cellBounds.Width, cellBounds.Height);
 
            // Resize propertyEditor control to cell bounds
            propertyEditor.Height = cellBounds.Height;
            propertyEditor.Width = cellBounds.Width;
 
            // Sets the cell's backcolor according to the data grid view's color
            propertyEditor.BackColor = this.DataGridView.Rows[rowIndex].Cells[this.ColumnIndex].Style.BackColor;
 
            // Finally paint the propertyEditor control            
            propertyEditor.DrawToBitmap(img, new Rectangle(0, 0, propertyEditor.Width, propertyEditor.Height));
            graphics.DrawImage(img, cellBounds.Location);
        }

This is working in Windows 7 but not in Windows XP.

 

Any ideas?

0 Kudos
Message 1 of 2
(5,006 Views)

Hi NI Engineers,

 

Is PropertyEditor and Ink control? If so, DrawToBitmap is not supporting it according to microsoft.

 

According to MSDN, The DrawToBitmap method has the following limitations:

  1. An ArgumentException might be thrown for large bitmaps. The maximum allowable size varies by machine.
  2. DrawToBitmap does not support the Ink controls for the Windows XP Tablet PC Edition 2005 operating system.
  3. DrawToBitmap does not draw a child TextBox if the Visible property of the TextBox is set to false.
  4. Controls inside containers are rendered in reverse order.
  5. DrawToBitmap is not fully functional for the RichTextBox; only the border of a bitmap is drawn.

 

Please, could you confirm me that? Is it the reason because DrawToBitmap is not generating the correct image? I work in a company and we have purchased your Measurement studio software so please, provide help.

 

Thanks in advance.

0 Kudos
Message 2 of 2
(4,972 Views)