本文整理汇总了C#中SourceGrid.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# SourceGrid.Refresh方法的具体用法?C# SourceGrid.Refresh怎么用?C# SourceGrid.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceGrid
的用法示例。
在下文中一共展示了SourceGrid.Refresh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindSourceGrid
/// <summary>
/// 为SourceGrid绑定数据源
/// </summary>
/// <param name="grid"></param>
/// <param name="data"></param>
public void BindSourceGrid(SourceGrid.Grid grid, DataTable data)
{
//byte[] imagebytes = null;
int[] ColumnWidth = new int[] { 120, 100, 100 };
//PopupMenu menuController = new PopupMenu();
if (grid.RowsCount > 0)
{
//清除原表格内容
grid.Rows.RemoveRange(0, grid.RowsCount);
}
//Redim grid
//grid.Redim(data.Rows.Count + grid.FixedRows, data.Columns.Count);
grid.SelectionMode = SourceGrid.GridSelectionMode.Row;//选行模式
grid.Selection.EnableMultiSelection = false; //行不允许多选
//grid.EnableSort = false; //不允许排序
grid.BorderStyle = BorderStyle.FixedSingle;
grid.ColumnsCount = 3;
grid.FixedRows = 1;
BuildGridColumnWidth(grid, ColumnWidth);
grid.Rows.Insert(0);
grid[0, 0] = new SourceGrid.Cells.ColumnHeader("用户名");
grid[0, 1] = new SourceGrid.Cells.ColumnHeader("姓名");
grid[0, 2] = new SourceGrid.Cells.ColumnHeader("用户角色");
grid[0, 1].View.Font = new Font("宋体", 10, FontStyle.Bold);
grid[0, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
for (int i = 1; i < data.Rows.Count + 1; i++)
{
grid.Rows.Insert(i);
//设置行高
grid.Rows.SetHeight(i, 30);
#region 表体塞值
//表体塞值
grid[i, 0] = new SourceGrid.Cells.Cell(data.Rows[i - 1][0], typeof(string)); //用户名
grid[i, 1] = new SourceGrid.Cells.Cell(data.Rows[i - 1][1], typeof(string));//姓名
//grid[i, 2] = new SourceGrid.Cells.Cell(data.Rows[i - 1][2], typeof(string));//用户角色
if (data.Rows[i - 1][2].ToString() == "0")
{
grid[i, 2] = new SourceGrid.Cells.Cell("普通用户", typeof(string));
}
else if (data.Rows[i - 1][2].ToString() == "1")
{
grid[i, 2] = new SourceGrid.Cells.Cell("管理员", typeof(string));
}
else
{
grid[i, 2] = new SourceGrid.Cells.Cell("未知角色", typeof(string));
}
#endregion
//设置单元格不可编辑
grid[i, 0].Editor.EnableEdit = false;
grid[i, 1].Editor.EnableEdit = false;
grid[i, 2].Editor.EnableEdit = false;
}
grid.Refresh();
}
示例2: BindSourceGrid
/// <summary>
/// 为SourceGrid绑定数据源
/// </summary>
/// <param name="grid"></param>
/// <param name="data"></param>
public void BindSourceGrid(SourceGrid.Grid grid, DataTable data, string colName)
{
int[] ColumnWidth = new int[] { 40, 200};
//PopupMenu menuController = new PopupMenu();
if (grid.RowsCount > 0)
{
//清除原表格内容
grid.Rows.RemoveRange(0, grid.RowsCount);
}
grid.SelectionMode = SourceGrid.GridSelectionMode.Row;//选行模式
grid.Selection.EnableMultiSelection = false; //行不允许多选
grid.BorderStyle = BorderStyle.FixedSingle;
grid.ColumnsCount = 2;
grid.FixedRows = 1;
BuildGridColumnWidth(grid, ColumnWidth);
grid.Rows.Insert(0);
grid[0, 0] = new SourceGrid.Cells.ColumnHeader("ID");
grid[0, 1] = new SourceGrid.Cells.ColumnHeader(colName);
grid[0, 1].View.Font = new Font("宋体", 10, FontStyle.Bold);
//隐藏列
grid[0, 0].Column.Visible = false;
grid[0, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
for (int i = 1; i < data.Rows.Count + 1; i++)
{
grid.Rows.Insert(i);
//设置行高
grid.Rows.SetHeight(i, 30);
#region 表体塞值
//表体塞值
grid[i, 0] = new SourceGrid.Cells.Cell(data.Rows[i - 1][0], typeof(int)); //id
grid[i, 1] = new SourceGrid.Cells.Cell(data.Rows[i - 1][1], typeof(string));//名称
#endregion
//设置单元格不可编辑
grid[i, 0].Editor.EnableEdit = false;
grid[i, 1].Editor.EnableEdit = false;
}
grid.Refresh();
}