本文整理汇总了C#中XPTable.Events.PaintCellEventArgs.SetCell方法的典型用法代码示例。如果您正苦于以下问题:C# PaintCellEventArgs.SetCell方法的具体用法?C# PaintCellEventArgs.SetCell怎么用?C# PaintCellEventArgs.SetCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XPTable.Events.PaintCellEventArgs
的用法示例。
在下文中一共展示了PaintCellEventArgs.SetCell方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaintCell
/// <summary>
/// Paints the Cell at the specified row and column indexes
/// </summary>
/// <param name="e">A PaintEventArgs that contains the event data</param>
/// <param name="row">The index of the row that contains the cell to be painted</param>
/// <param name="column">The index of the column that contains the cell to be painted</param>
/// <param name="cellRect">The bounding Rectangle of the Cell</param>
protected void OnPaintCell(PaintEventArgs e, int row, int column, Rectangle cellRect)
{
if (row == 0 && column == 1)
{
column = 1;
}
// get the renderer for the cells column
ICellRenderer renderer = this.ColumnModel.Columns[column].Renderer;
if (renderer == null)
{
// get the default renderer for the column
renderer = this.ColumnModel.GetCellRenderer(this.ColumnModel.Columns[column].GetDefaultRendererName());
}
// if the renderer is still null (which it shouldn't)
// the get out of here
if (renderer == null)
{
return;
}
////////////
// Adjust the rectangle for this cell to include any cells that it colspans over
Rectangle realRect = cellRect;
Cell thisCell = this.TableModel[row, column];
if (thisCell != null && thisCell.ColSpan > 1)
{
int width = this.GetColumnWidth(column, thisCell);
realRect = new Rectangle(cellRect.X, cellRect.Y, width, cellRect.Height);
}
////////////
// For the last column, extend the width of the cell to fill the grid, including the vertical scrollbar (to avoid a blank space where the scrollbar would be).
if (column == this.ColumnModel.Columns.Count - 1)
{
//realRect.Width += SystemInformation.VerticalScrollBarWidth;
}
PaintCellEventArgs pcea = new PaintCellEventArgs(e.Graphics, realRect);
if (thisCell != null && thisCell.ImageSizeMode == ImageSizeMode.NoClip)
{
pcea.Graphics.SetClip(e.ClipRectangle);
}
else
{
pcea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, realRect));
}
if (column < this.TableModel.Rows[row].Cells.Count)
{
// is the cell selected
bool selected = false;
if (this.FullRowSelect)
{
selected = this.TableModel.Selections.IsRowSelected(row);
}
else
{
if (this.SelectionStyle == SelectionStyle.ListView)
{
if (this.TableModel.Selections.IsRowSelected(row) && this.ColumnModel.PreviousVisibleColumn(column) == -1)
{
selected = true;
}
}
else if (this.SelectionStyle == SelectionStyle.Grid)
{
if (this.TableModel.Selections.IsCellSelected(row, column))
{
selected = true;
}
}
}
//
bool editable = this.TableModel[row, column].Editable && this.TableModel.Rows[row].Editable && this.ColumnModel.Columns[column].Editable;
bool enabled = this.TableModel[row, column].Enabled && this.TableModel.Rows[row].Enabled && this.ColumnModel.Columns[column].Enabled;
// draw the cell
pcea.SetCell(this.TableModel[row, column]);
pcea.SetRow(row);
pcea.SetColumn(column);
pcea.SetTable(this);
pcea.SetSelected(selected);
pcea.SetFocused(this.Focused && this.FocusedCell.Row == row && this.FocusedCell.Column == column);
pcea.SetSorted(column == this.lastSortedColumn);
pcea.SetEditable(editable);
pcea.SetEnabled(enabled);
pcea.SetCellRect(realRect);
}
//.........这里部分代码省略.........
示例2: OnPaintCell
/// <summary>
/// Paints the Cell at the specified row and column indexes
/// </summary>
/// <param name="e">A PaintEventArgs that contains the event data</param>
/// <param name="row">The index of the row that contains the cell to be painted</param>
/// <param name="column">The index of the column that contains the cell to be painted</param>
/// <param name="cellRect">The bounding Rectangle of the Cell</param>
protected void OnPaintCell(PaintEventArgs e, int row, int column, Rectangle cellRect)
{
if (row == 0 && column == 1)
{
column = 1;
}
// get the renderer for the cells column
ICellRenderer renderer = this.ColumnModel.Columns[column].Renderer;
if (renderer == null)
{
// get the default renderer for the column
renderer = this.ColumnModel.GetCellRenderer(this.ColumnModel.Columns[column].GetDefaultRendererName());
}
// if the renderer is still null (which it shouldn't)
// the get out of here
if (renderer == null)
{
return;
}
PaintCellEventArgs pcea = new PaintCellEventArgs(e.Graphics, cellRect);
pcea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, cellRect));
if (column < this.TableModel.Rows[row].Cells.Count)
{
// is the cell selected
bool selected = false;
if (this.FullRowSelect)
{
selected = this.TableModel.Selections.IsRowSelected(row);
}
else
{
if (this.SelectionStyle == SelectionStyle.ListView)
{
if (this.TableModel.Selections.IsRowSelected(row) && this.ColumnModel.PreviousVisibleColumn(column) == -1)
{
selected = true;
}
}
else if (this.SelectionStyle == SelectionStyle.Grid)
{
if (this.TableModel.Selections.IsCellSelected(row, column))
{
selected = true;
}
}
}
//
bool editable = this.TableModel[row, column].Editable && this.TableModel.Rows[row].Editable && this.ColumnModel.Columns[column].Editable;
bool enabled = this.TableModel[row, column].Enabled && this.TableModel.Rows[row].Enabled && this.ColumnModel.Columns[column].Enabled;
// draw the cell
pcea.SetCell(this.TableModel[row, column]);
pcea.SetRow(row);
pcea.SetColumn(column);
pcea.SetTable(this);
pcea.SetSelected(selected);
pcea.SetFocused(this.Focused && this.FocusedCell.Row == row && this.FocusedCell.Column == column);
pcea.SetSorted(column == this.lastSortedColumn);
pcea.SetEditable(editable);
pcea.SetEnabled(enabled);
pcea.SetCellRect(cellRect);
}
else
{
// there isn't a cell for this column, so send a
// null value for the cell and the renderer will
// take care of the rest (it should draw an empty cell)
pcea.SetCell(null);
pcea.SetRow(row);
pcea.SetColumn(column);
pcea.SetTable(this);
pcea.SetSelected(false);
pcea.SetFocused(false);
pcea.SetSorted(false);
pcea.SetEditable(false);
pcea.SetEnabled(false);
pcea.SetCellRect(cellRect);
}
// let the user get the first crack at painting the cell
this.OnBeforePaintCell(pcea);
// only send to the renderer if the user hasn't
// set the handled property
if (!pcea.Handled)
{
//.........这里部分代码省略.........
示例3: OnPaintCell
/// <summary>
/// Paints the Cell at the specified row and column indexes
/// </summary>
/// <param name="e">A PaintEventArgs that contains the event data</param>
/// <param name="row">The index of the row that contains the cell to be painted</param>
/// <param name="column">The index of the column that contains the cell to be painted</param>
/// <param name="cellRect">The bounding Rectangle of the Cell</param>
protected void OnPaintCell(PaintEventArgs e, int row, int column, Rectangle cellRect)
{
if (this.TableModel == null || this.ColumnModel == null)
{
return;
}
var currentCell = this.TableModel[row, column];
var currentRow = this.TableModel.Rows[row];
var currentColumn = this.ColumnModel.Columns[column];
if (currentColumn == null)
{
return;
}
// get the renderer for the cells column
ICellRenderer renderer = currentColumn.Renderer;
if (renderer == null)
{
// get the default renderer for the column
renderer = this.ColumnModel.GetCellRenderer(currentColumn.GetDefaultRendererName());
}
// if the renderer is still null (which it shouldn't)
// the get out of here
if (renderer == null)
{
return;
}
////////////
// Adjust the rectangle for this cell to include any cells that it colspans over
Rectangle realRect = cellRect;
var pcea = new PaintCellEventArgs(e.Graphics, realRect);
bool isEnabled = false;
bool isEditable = false;
if (currentCell != null)
{
isEditable = currentCell.Editable && currentRow.Editable && currentColumn.Editable;
isEnabled = currentCell.Enabled && currentRow.Enabled && currentColumn.Enabled;
if (currentCell.ColSpan > 1)
{
int width = this.GetColumnWidth(column, currentCell);
realRect = new Rectangle(cellRect.X, cellRect.Y, width, cellRect.Height);
}
if (currentCell.ImageSizeMode == ImageSizeMode.NoClip)
{
pcea.Graphics.SetClip(e.ClipRectangle);
}
else
{
pcea.Graphics.SetClip(Rectangle.Intersect(e.ClipRectangle, realRect));
}
}
if (column < currentRow.Cells.Count)
{
// is the cell selected
bool isSelected = false;
if (this.FullRowSelect)
{
isSelected = this.TableModel.Selections.IsRowSelected(row);
}
else
{
if (this.SelectionStyle == SelectionStyle.ListView)
{
if (this.TableModel.Selections.IsRowSelected(row) && this.ColumnModel.PreviousVisibleColumn(column) == -1)
{
isSelected = true;
}
}
else if (this.SelectionStyle == SelectionStyle.Grid)
{
if (this.TableModel.Selections.IsCellSelected(row, column))
{
isSelected = true;
}
}
}
// draw the cell
pcea.SetCell(currentCell);
pcea.SetRow(row);
pcea.SetColumn(column);
pcea.SetTable(this);
pcea.SetSelected(isSelected);
pcea.SetFocused(this.Focused && this.FocusedCell.Row == row && this.FocusedCell.Column == column);
//.........这里部分代码省略.........