private void FGrid_CustomDrawCellForeground(object sender, iGCustomDrawCellEventArgs e) { if (IsButtonColumn(e.ColIndex) && IsCellButtonVisible(e.RowIndex, e.ColIndex)) { iGCell myCell = fGrid.Cells[e.RowIndex, e.ColIndex]; //myCell.ImageIndex = 6; // Determine the button state. PushButtonState myState; switch (e.State) { case iGControlState.Normal: myState = PushButtonState.Normal; break; case iGControlState.Hot: myState = PushButtonState.Hot; break; case iGControlState.Pressed: myState = PushButtonState.Pressed; break; default: myState = PushButtonState.Disabled; break; } // Draw a button cell. Image myImage = null; if ((fGrid.ImageList != null) && (myCell.ImageIndex > -1)) { myImage = fGrid.ImageList.Images[myCell.ImageIndex]; } if (myImage == null) { ButtonRenderer.DrawButton(e.Graphics, e.Bounds, myCell.Text, myCell.EffectiveFont, false, myState); } else { Rectangle myImageRect = new Rectangle(0, 0, myImage.Width, myImage.Height); CenterRect(e.Bounds, ref myImageRect); ButtonRenderer.DrawButton(e.Graphics, e.Bounds, null, myCell.EffectiveFont, myImage, myImageRect, false, myState); } } }
private void fGrid_CustomDrawCellForeground(object sender, iGCustomDrawCellEventArgs e) { Image cell_img = (Image)fGrid.Cells[e.RowIndex, e.ColIndex].Value; if (cell_img == null) { return; } //caused error the other time Region myOldClipRegion = e.Graphics.Clip; e.Graphics.SetClip(new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)); try { e.Graphics.DrawImage(cell_img, new Rectangle(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height - cell_img.Height) / 2, cell_img.Width, cell_img.Height)); } finally { e.Graphics.Clip = myOldClipRegion; } }