Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / DataGridViewCellPaintingEventArgs.cs / 1 / DataGridViewCellPaintingEventArgs.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms
{
using System;
using System.Drawing;
using System.Diagnostics;
using System.ComponentModel;
///
public class DataGridViewCellPaintingEventArgs : HandledEventArgs
{
private DataGridView dataGridView;
private Graphics graphics;
private Rectangle clipBounds;
private Rectangle cellBounds;
private int rowIndex, columnIndex;
private DataGridViewElementStates cellState;
private object value;
private object formattedValue;
private string errorText;
private DataGridViewCellStyle cellStyle;
private DataGridViewAdvancedBorderStyle advancedBorderStyle;
private DataGridViewPaintParts paintParts;
///
public DataGridViewCellPaintingEventArgs(DataGridView dataGridView,
Graphics graphics,
Rectangle clipBounds,
Rectangle cellBounds,
int rowIndex,
int columnIndex,
DataGridViewElementStates cellState,
object value,
object formattedValue,
string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
if (dataGridView == null)
{
throw new ArgumentNullException("dataGridView");
}
if (graphics == null)
{
throw new ArgumentNullException("graphics");
}
if (cellStyle == null)
{
throw new ArgumentNullException("cellStyle");
}
if ((paintParts & ~DataGridViewPaintParts.All) != 0)
{
throw new ArgumentException(SR.GetString(SR.DataGridView_InvalidDataGridViewPaintPartsCombination, "paintParts"));
}
this.graphics = graphics;
this.clipBounds = clipBounds;
this.cellBounds = cellBounds;
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.cellState = cellState;
this.value = value;
this.formattedValue = formattedValue;
this.errorText = errorText;
this.cellStyle = cellStyle;
this.advancedBorderStyle = advancedBorderStyle;
this.paintParts = paintParts;
}
internal DataGridViewCellPaintingEventArgs(DataGridView dataGridView)
{
Debug.Assert(dataGridView != null);
this.dataGridView = dataGridView;
}
///
public DataGridViewAdvancedBorderStyle AdvancedBorderStyle
{
get
{
return this.advancedBorderStyle;
}
}
///
public Rectangle CellBounds
{
get
{
return this.cellBounds;
}
}
///
public DataGridViewCellStyle CellStyle
{
get
{
return this.cellStyle;
}
}
///
public Rectangle ClipBounds
{
get
{
return this.clipBounds;
}
}
///
public int ColumnIndex
{
get
{
return this.columnIndex;
}
}
///
public string ErrorText
{
get
{
return this.errorText;
}
}
///
public object FormattedValue
{
get
{
return this.formattedValue;
}
}
///
public Graphics Graphics
{
get
{
return this.graphics;
}
}
///
public DataGridViewPaintParts PaintParts
{
get
{
return this.paintParts;
}
}
///
public int RowIndex
{
get
{
return this.rowIndex;
}
}
///
public DataGridViewElementStates State
{
get
{
return this.cellState;
}
}
///
public object Value
{
get
{
return this.value;
}
}
///
public void Paint(Rectangle clipBounds, DataGridViewPaintParts paintParts)
{
if (this.rowIndex < -1 || this.rowIndex >= this.dataGridView.Rows.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_RowIndexOutOfRange));
}
if (this.columnIndex < -1 || this.columnIndex >= this.dataGridView.Columns.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange));
}
this.dataGridView.GetCellInternal(this.columnIndex, this.rowIndex).PaintInternal(this.graphics,
clipBounds,
this.cellBounds,
this.rowIndex,
this.cellState,
this.value,
this.formattedValue,
this.errorText,
this.cellStyle,
this.advancedBorderStyle,
paintParts);
}
///
public void PaintBackground(Rectangle clipBounds, bool cellsPaintSelectionBackground)
{
if (this.rowIndex < -1 || this.rowIndex >= this.dataGridView.Rows.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_RowIndexOutOfRange));
}
if (this.columnIndex < -1 || this.columnIndex >= this.dataGridView.Columns.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange));
}
DataGridViewPaintParts paintParts = DataGridViewPaintParts.Background | DataGridViewPaintParts.Border;
if (cellsPaintSelectionBackground)
{
paintParts |= DataGridViewPaintParts.SelectionBackground;
}
this.dataGridView.GetCellInternal(this.columnIndex, this.rowIndex).PaintInternal(this.graphics,
clipBounds,
this.cellBounds,
this.rowIndex,
this.cellState,
this.value,
this.formattedValue,
this.errorText,
this.cellStyle,
this.advancedBorderStyle,
paintParts);
}
///
public void PaintContent(Rectangle clipBounds)
{
if (this.rowIndex < -1 || this.rowIndex >= this.dataGridView.Rows.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_RowIndexOutOfRange));
}
if (this.columnIndex < -1 || this.columnIndex >= this.dataGridView.Columns.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange));
}
this.dataGridView.GetCellInternal(this.columnIndex, this.rowIndex).PaintInternal(this.graphics,
clipBounds,
this.cellBounds,
this.rowIndex,
this.cellState,
this.value,
this.formattedValue,
this.errorText,
this.cellStyle,
this.advancedBorderStyle,
DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon);
}
internal void SetProperties(Graphics graphics,
Rectangle clipBounds,
Rectangle cellBounds,
int rowIndex,
int columnIndex,
DataGridViewElementStates cellState,
object value,
object formattedValue,
string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
Debug.Assert(graphics != null);
Debug.Assert(cellStyle != null);
this.graphics = graphics;
this.clipBounds = clipBounds;
this.cellBounds = cellBounds;
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.cellState = cellState;
this.value = value;
this.formattedValue = formattedValue;
this.errorText = errorText;
this.cellStyle = cellStyle;
this.advancedBorderStyle = advancedBorderStyle;
this.paintParts = paintParts;
this.Handled = false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Windows.Forms
{
using System;
using System.Drawing;
using System.Diagnostics;
using System.ComponentModel;
///
public class DataGridViewCellPaintingEventArgs : HandledEventArgs
{
private DataGridView dataGridView;
private Graphics graphics;
private Rectangle clipBounds;
private Rectangle cellBounds;
private int rowIndex, columnIndex;
private DataGridViewElementStates cellState;
private object value;
private object formattedValue;
private string errorText;
private DataGridViewCellStyle cellStyle;
private DataGridViewAdvancedBorderStyle advancedBorderStyle;
private DataGridViewPaintParts paintParts;
///
public DataGridViewCellPaintingEventArgs(DataGridView dataGridView,
Graphics graphics,
Rectangle clipBounds,
Rectangle cellBounds,
int rowIndex,
int columnIndex,
DataGridViewElementStates cellState,
object value,
object formattedValue,
string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
if (dataGridView == null)
{
throw new ArgumentNullException("dataGridView");
}
if (graphics == null)
{
throw new ArgumentNullException("graphics");
}
if (cellStyle == null)
{
throw new ArgumentNullException("cellStyle");
}
if ((paintParts & ~DataGridViewPaintParts.All) != 0)
{
throw new ArgumentException(SR.GetString(SR.DataGridView_InvalidDataGridViewPaintPartsCombination, "paintParts"));
}
this.graphics = graphics;
this.clipBounds = clipBounds;
this.cellBounds = cellBounds;
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.cellState = cellState;
this.value = value;
this.formattedValue = formattedValue;
this.errorText = errorText;
this.cellStyle = cellStyle;
this.advancedBorderStyle = advancedBorderStyle;
this.paintParts = paintParts;
}
internal DataGridViewCellPaintingEventArgs(DataGridView dataGridView)
{
Debug.Assert(dataGridView != null);
this.dataGridView = dataGridView;
}
///
public DataGridViewAdvancedBorderStyle AdvancedBorderStyle
{
get
{
return this.advancedBorderStyle;
}
}
///
public Rectangle CellBounds
{
get
{
return this.cellBounds;
}
}
///
public DataGridViewCellStyle CellStyle
{
get
{
return this.cellStyle;
}
}
///
public Rectangle ClipBounds
{
get
{
return this.clipBounds;
}
}
///
public int ColumnIndex
{
get
{
return this.columnIndex;
}
}
///
public string ErrorText
{
get
{
return this.errorText;
}
}
///
public object FormattedValue
{
get
{
return this.formattedValue;
}
}
///
public Graphics Graphics
{
get
{
return this.graphics;
}
}
///
public DataGridViewPaintParts PaintParts
{
get
{
return this.paintParts;
}
}
///
public int RowIndex
{
get
{
return this.rowIndex;
}
}
///
public DataGridViewElementStates State
{
get
{
return this.cellState;
}
}
///
public object Value
{
get
{
return this.value;
}
}
///
public void Paint(Rectangle clipBounds, DataGridViewPaintParts paintParts)
{
if (this.rowIndex < -1 || this.rowIndex >= this.dataGridView.Rows.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_RowIndexOutOfRange));
}
if (this.columnIndex < -1 || this.columnIndex >= this.dataGridView.Columns.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange));
}
this.dataGridView.GetCellInternal(this.columnIndex, this.rowIndex).PaintInternal(this.graphics,
clipBounds,
this.cellBounds,
this.rowIndex,
this.cellState,
this.value,
this.formattedValue,
this.errorText,
this.cellStyle,
this.advancedBorderStyle,
paintParts);
}
///
public void PaintBackground(Rectangle clipBounds, bool cellsPaintSelectionBackground)
{
if (this.rowIndex < -1 || this.rowIndex >= this.dataGridView.Rows.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_RowIndexOutOfRange));
}
if (this.columnIndex < -1 || this.columnIndex >= this.dataGridView.Columns.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange));
}
DataGridViewPaintParts paintParts = DataGridViewPaintParts.Background | DataGridViewPaintParts.Border;
if (cellsPaintSelectionBackground)
{
paintParts |= DataGridViewPaintParts.SelectionBackground;
}
this.dataGridView.GetCellInternal(this.columnIndex, this.rowIndex).PaintInternal(this.graphics,
clipBounds,
this.cellBounds,
this.rowIndex,
this.cellState,
this.value,
this.formattedValue,
this.errorText,
this.cellStyle,
this.advancedBorderStyle,
paintParts);
}
///
public void PaintContent(Rectangle clipBounds)
{
if (this.rowIndex < -1 || this.rowIndex >= this.dataGridView.Rows.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_RowIndexOutOfRange));
}
if (this.columnIndex < -1 || this.columnIndex >= this.dataGridView.Columns.Count)
{
throw new InvalidOperationException(SR.GetString(SR.DataGridViewElementPaintingEventArgs_ColumnIndexOutOfRange));
}
this.dataGridView.GetCellInternal(this.columnIndex, this.rowIndex).PaintInternal(this.graphics,
clipBounds,
this.cellBounds,
this.rowIndex,
this.cellState,
this.value,
this.formattedValue,
this.errorText,
this.cellStyle,
this.advancedBorderStyle,
DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon);
}
internal void SetProperties(Graphics graphics,
Rectangle clipBounds,
Rectangle cellBounds,
int rowIndex,
int columnIndex,
DataGridViewElementStates cellState,
object value,
object formattedValue,
string errorText,
DataGridViewCellStyle cellStyle,
DataGridViewAdvancedBorderStyle advancedBorderStyle,
DataGridViewPaintParts paintParts)
{
Debug.Assert(graphics != null);
Debug.Assert(cellStyle != null);
this.graphics = graphics;
this.clipBounds = clipBounds;
this.cellBounds = cellBounds;
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.cellState = cellState;
this.value = value;
this.formattedValue = formattedValue;
this.errorText = errorText;
this.cellStyle = cellStyle;
this.advancedBorderStyle = advancedBorderStyle;
this.paintParts = paintParts;
this.Handled = false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- VisualBasicSettings.cs
- UrlRoutingModule.cs
- Section.cs
- MenuEventArgs.cs
- KeyedQueue.cs
- ExpandableObjectConverter.cs
- GradientSpreadMethodValidation.cs
- PersianCalendar.cs
- HasRunnableWorkflowEvent.cs
- ManipulationDeltaEventArgs.cs
- CreateRefExpr.cs
- UpDownEvent.cs
- Knowncolors.cs
- ServiceEndpoint.cs
- SocketAddress.cs
- VisualTreeUtils.cs
- SkinBuilder.cs
- RTLAwareMessageBox.cs
- PageAdapter.cs
- ListView.cs
- SerialStream.cs
- ExpressionTable.cs
- EventHandlerList.cs
- XDRSchema.cs
- ObjectAssociationEndMapping.cs
- SendingRequestEventArgs.cs
- SharedPerformanceCounter.cs
- ServiceXNameTypeConverter.cs
- IgnoreFlushAndCloseStream.cs
- HotSpotCollection.cs
- AttributeEmitter.cs
- DocobjHost.cs
- FactoryId.cs
- Win32.cs
- SessionIDManager.cs
- VisualBrush.cs
- HostProtectionPermission.cs
- ByteViewer.cs
- ShaperBuffers.cs
- _CookieModule.cs
- CompositeCollection.cs
- APCustomTypeDescriptor.cs
- HttpConfigurationSystem.cs
- BindToObject.cs
- VirtualizingPanel.cs
- DllNotFoundException.cs
- FrameworkReadOnlyPropertyMetadata.cs
- NullableLongSumAggregationOperator.cs
- ProfileInfo.cs
- ImageUrlEditor.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- QuotaExceededException.cs
- PolygonHotSpot.cs
- SemaphoreSlim.cs
- DrawingVisual.cs
- _NtlmClient.cs
- DetailsViewUpdateEventArgs.cs
- _BufferOffsetSize.cs
- X509ChainPolicy.cs
- RemotingAttributes.cs
- tibetanshape.cs
- MouseGestureConverter.cs
- LayoutExceptionEventArgs.cs
- HyperLink.cs
- TimelineClockCollection.cs
- LicenseException.cs
- ContentElementAutomationPeer.cs
- DataGridViewImageColumn.cs
- CalendarItem.cs
- GlobalizationAssembly.cs
- HMACSHA256.cs
- AlphabeticalEnumConverter.cs
- ParameterModifier.cs
- CanExecuteRoutedEventArgs.cs
- StorageAssociationSetMapping.cs
- MediaContext.cs
- UIElementAutomationPeer.cs
- XmlMemberMapping.cs
- InstanceValue.cs
- ToolStripItemDataObject.cs
- AuthenticationModulesSection.cs
- DragDropHelper.cs
- CompiledELinqQueryState.cs
- ParameterEditorUserControl.cs
- DiscoveryServiceExtension.cs
- AnnotationResource.cs
- DebugHandleTracker.cs
- ServiceInfo.cs
- InkSerializer.cs
- DataColumnChangeEvent.cs
- ImageCollectionEditor.cs
- Rotation3DKeyFrameCollection.cs
- MatrixTransform3D.cs
- DataBindingCollectionEditor.cs
- XmlEventCache.cs
- ChannelManager.cs
- WindowsPrincipal.cs
- BuilderPropertyEntry.cs
- ParameterBuilder.cs
- DrawItemEvent.cs