本文整理汇总了C#中System.Windows.Forms.DataGridTableStyle类的典型用法代码示例。如果您正苦于以下问题:C# DataGridTableStyle类的具体用法?C# DataGridTableStyle怎么用?C# DataGridTableStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridTableStyle类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridTableStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: generatedatagrid
public void generatedatagrid()
{
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = arr1.GetType().Name;
DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
tbcName.Width = dataGrid1.Width * 50 / 100;
tbcName.MappingName = "EPC";
tbcName.HeaderText = "EPC";
tableStyle.GridColumnStyles.Add(tbcName);
tbcName = new DataGridTextBoxColumn();
tbcName.Width = dataGrid1.Width * 20 / 100;
tbcName.MappingName = "Timestamp";
tbcName.HeaderText = "Timestamp";
tableStyle.GridColumnStyles.Add(tbcName);
tbcName = new DataGridTextBoxColumn();
tbcName.Width = dataGrid1.Width * 15 / 100;
tbcName.MappingName = "ReadCount";
tbcName.HeaderText = "ReadCount";
tableStyle.GridColumnStyles.Add(tbcName);
tbcName = new DataGridTextBoxColumn();
tbcName.Width = dataGrid1.Width * 12 / 100;
tbcName.MappingName = "Rssi";
tbcName.HeaderText = "Rssi";
tableStyle.GridColumnStyles.Add(tbcName);
dataGrid1.TableStyles.Clear();
dataGrid1.TableStyles.Add(tableStyle);
}
示例2: InitGrid
private void InitGrid()
{
grid.ReadOnly = true;
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "SmtpFilters";
DataGridNoActiveCellColumn TextCol = new DataGridNoActiveCellColumn();
TextCol.MappingName = "Cost";
TextCol.HeaderText = "Cost";
TextCol.Width = 50;
ts1.GridColumnStyles.Add(TextCol);
DataGridNoActiveCellColumn TextCol2 = new DataGridNoActiveCellColumn();
TextCol2.MappingName = "Description";
TextCol2.HeaderText = "Description";
TextCol2.Width = 150;
ts1.GridColumnStyles.Add(TextCol2);
DataGridNoActiveCellColumn TextCol3 = new DataGridNoActiveCellColumn();
TextCol3.MappingName = "Assembly";
TextCol3.HeaderText = "Assembly";
TextCol3.Width = 150;
ts1.GridColumnStyles.Add(TextCol3);
DataGridNoActiveCellColumn TextCol4 = new DataGridNoActiveCellColumn();
TextCol4.MappingName = "ClassName";
TextCol4.HeaderText = "ClassName";
TextCol4.Width = 225;
ts1.GridColumnStyles.Add(TextCol4);
ts1.AllowSorting = false;
grid.TableStyles.Add(ts1);
}
示例3: getTableStyle
public DataGridTableStyle getTableStyle()
{
DataGridTableStyle style = new DataGridTableStyle();
style.MappingName = "ArrayList";
DataGridTextBoxColumn column = new DataGridTextBoxColumn();
column.MappingName = "Name";
column.HeaderText = "Name";
column.Format = "f4";
column.Width = 150;
style.GridColumnStyles.Add(column);
column = new DataGridTextBoxColumn();
column.MappingName = "Status";
column.HeaderText = "Completed";
column.Format = "f4";
column.Width = 85;
style.GridColumnStyles.Add(column);
column = new DataGridTextBoxColumn();
column.MappingName = "SupportID";
column.HeaderText = "SupportID";
column.Format = "d";
column.Width = 25;
style.GridColumnStyles.Add(column);
column = new DataGridTextBoxColumn();
column.MappingName = "StatusID";
column.HeaderText = "StatusID";
column.Format = "d";
column.Width = 25;
style.GridColumnStyles.Add(column);
return style;
}
示例4: InitializeLogColumns
public static DataGridTableStyle InitializeLogColumns(this ILogFieldProvider stratum, EditableDataGrid grid)
{
DataGridTableStyle tblStyle = new DataGridTableStyle();
tblStyle.MappingName = "LogDO";
foreach (LogFieldSetupDO field in stratum.LogFields)
{
CustomColumnBase col = MakeColumn(field.ColumnType);
col.MappingName = field.Field;
col.HeaderText = field.Heading;
col.Format = field.Format; // 'C' = currency, 'N' = number (E.G. "N1" means one decimal place), #0.00
col.FormatInfo = null;
col.NullText = String.Empty;// <- look into this
if (field.Width == 0.0)
{
col.Width = MeasureTextWidth(grid, field.Heading.Trim()) + 18;//plus 18 to allow for padding
}
else
{
col.Width = (int)field.Width;
}
tblStyle.GridColumnStyles.Add(col);
}
grid.TableStyles.Add(tblStyle);
return tblStyle;
}
示例5: frmStock_Items
public static DataGridTableStyle frmStock_Items()
{
DataGridTableStyle dtStyle = new DataGridTableStyle();
dtStyle.MappingName = "table";
DataGridTextBoxColumn id = new DataGridTextBoxColumn();
id.MappingName = "id";
id.HeaderText = "ID";
id.Width = 30;
dtStyle.GridColumnStyles.Add(id);
DataGridTextBoxColumn lotno = new DataGridTextBoxColumn();
lotno.MappingName = "lot_no";
lotno.HeaderText = "Lot#";
lotno.Width = 80;
dtStyle.GridColumnStyles.Add(lotno);
DataGridTextBoxColumn qty = new DataGridTextBoxColumn();
qty.MappingName = "qty";
qty.HeaderText = "Qty";
qty.Width = 96;
dtStyle.GridColumnStyles.Add(qty);
return dtStyle;
}
示例6: dgPickTaskDataBind
private void dgPickTaskDataBind(bool isReset)
{
this.ts = new DataGridTableStyle();
this.ts.MappingName = new PickTask[] { }.GetType().Name;
this.ts.GridColumnStyles.Add(this.columnPickId);
this.ts.GridColumnStyles.Add(this.columnOrderNo);
this.ts.GridColumnStyles.Add(this.columnFlow);
this.ts.GridColumnStyles.Add(this.columnItemDescription);
this.ts.GridColumnStyles.Add(this.columnItemCode);
this.ts.GridColumnStyles.Add(this.columnOrderedQty);
this.ts.GridColumnStyles.Add(this.columnPickedQty);
this.ts.GridColumnStyles.Add(this.columnUom);
this.ts.GridColumnStyles.Add(this.columnUnitCount);
this.ts.GridColumnStyles.Add(this.columnWindowTime);
this.ts.GridColumnStyles.Add(this.columnReleaseTime);
this.ts.GridColumnStyles.Add(this.columnManufactureParty);
this.dgPickTask.TableStyles.Clear();
this.dgPickTask.TableStyles.Add(this.ts);
if (isReset)
{
this.dgPickTask.DataSource = new PickTask[] { };
}
else
{
PickTask[] pts = this.smartDeviceService.GetPickerTasks(user.Code);
this.dgPickTask.DataSource = pts;
}
this.ResumeLayout();
}
示例7: TestAdd
public void TestAdd ()
{
DataGridTableStyle ts = new DataGridTableStyle ();
GridColumnStylesCollection sc = ts.GridColumnStyles;
sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionEventHandler);
// Add single
ResetEventData ();
DataGridTextBoxColumn col1 = new DataGridTextBoxColumn ();
col1.MappingName = "Column1";
sc.Add (col1);
Assert.AreEqual (true, eventhandled);
Assert.AreEqual (col1, Element);
Assert.AreEqual (CollectionChangeAction.Add, Action);
// Add multiple
ResetEventData ();
DataGridTextBoxColumn elem1 = new DataGridTextBoxColumn ();
DataGridTextBoxColumn elem2 = new DataGridTextBoxColumn ();
sc.AddRange (new DataGridTextBoxColumn [] {elem1, elem2});
Assert.AreEqual (true, eventhandled, "A1");
Assert.AreEqual (CollectionChangeAction.Add, Action, "A2");
Assert.AreEqual (elem2, Element, "A3");
}
示例8: SetGridDataSource
public static void SetGridDataSource(DataGrid grid, object dataSource) {
grid.DataSource = dataSource;
DataGridTableStyle ts = new DataGridTableStyle((CurrencyManager) grid.BindingContext[dataSource]);
grid.TableStyles.Clear();
grid.TableStyles.Add(ts);
ts.GridColumnStyles.Clear();
}
示例9: InitGrid
/// <summary>
/// 初始化表格控件
/// </summary>
private void InitGrid()
{
var dgts = new DataGridTableStyle { MappingName = prods.ProDelivery.TableName };
DataGridColumnStyle dgRowNo = new DataGridTextBoxColumn();
dgRowNo.Width = 40;
dgRowNo.MappingName = prods.ProDelivery.RowNoColumn.ColumnName;
dgRowNo.HeaderText = "序号";
dgts.GridColumnStyles.Add(dgRowNo);
//DataGridColumnStyle dgAutoID = new DataGridTextBoxColumn();
//dgAutoID.Width = 40;
//dgAutoID.MappingName = "AutoID";
//dgAutoID.HeaderText = "";
//dgts.GridColumnStyles.Add(dgAutoID);
DataGridColumnStyle dgccOrderNumber = new DataGridTextBoxColumn();
dgccOrderNumber.Width = 120;
dgccOrderNumber.MappingName = "cCode";
dgccOrderNumber.HeaderText = "单号";
dgts.GridColumnStyles.Add(dgccOrderNumber);
DataGridColumnStyle dgccCusName = new DataGridTextBoxColumn();
dgccCusName.Width = 70;
dgccCusName.MappingName = "cCusName";
dgccCusName.HeaderText = "客户";
dgts.GridColumnStyles.Add(dgccCusName);
DataGridColumnStyle dgccMaker = new DataGridTextBoxColumn();
dgccMaker.Width = 70;
dgccMaker.MappingName = "cMaker";
dgccMaker.HeaderText = "制单人";
dgts.GridColumnStyles.Add(dgccMaker);
DataGridColumnStyle dgccDepName = new DataGridTextBoxColumn();
dgccDepName.Width = 70;
dgccDepName.MappingName = "cDepName";
dgccDepName.HeaderText = "部门";
dgts.GridColumnStyles.Add(dgccDepName);
DataGridColumnStyle dgcMemo = new DataGridTextBoxColumn();
dgcMemo.Width = 70;
dgcMemo.MappingName = "cMemo";
dgcMemo.HeaderText = "备注";
dgts.GridColumnStyles.Add(dgcMemo);
DataGridColumnStyle dgccVerifyState = new DataGridTextBoxColumn();
dgccVerifyState.Width = 70;
dgccVerifyState.MappingName = "cVerifyState";
dgccVerifyState.HeaderText = "状态";
dgts.GridColumnStyles.Add(dgccVerifyState);
dGridMain.TableStyles.Clear();
dGridMain.TableStyles.Add(dgts);
dGridMain.DataSource = prods.ProDelivery;
}
示例10: GridTableStylesCollectionTests
public GridTableStylesCollectionTests ()
{
DataGrid grid = new DataGrid ();
GridTableStylesCollection sc = grid.TableStyles;
sc.CollectionChanged += new CollectionChangeEventHandler (OnCollectionChanged);
Console.WriteLine ("GridColumnStylesCollection default --- ");
DumpGridTableStylesCollection (sc);
Console.WriteLine ("Add single item");
DataGridTableStyle ts = new DataGridTableStyle ();
ts.MappingName = "Table1";
sc.Add (ts);
Console.WriteLine ("Add multipleitems");
sc.AddRange (new DataGridTableStyle [] {new DataGridTableStyle (), new DataGridTableStyle ()});
Console.WriteLine ("Remove At");
sc.RemoveAt (2);
Console.WriteLine ("Add single item");
ts = new DataGridTableStyle ();
ts.MappingName = "Table2";
sc.Add (ts);
for (int i = 0; i < sc.Count; i ++)
Console.WriteLine ("Element {0}:{1}", i, sc[i].MappingName);
sc.Remove (ts);
Console.WriteLine ("Contains Table1 {0}", sc.Contains ("Table1"));
Console.WriteLine ("Contains Table4 {0}", sc.Contains ("Table4"));
}
示例11: CreateDataGridTableStyle
public static DataGridTableStyle CreateDataGridTableStyle(string tableMappingName, string[] dbColName,
string[] dgShowName, int[] boolColumnIndex, int [] columnWidth )
{
ArgumentChecker.CheckNotNull(dbColName);
ArgumentChecker.CheckNotNull(dgShowName);
if ( dbColName.Length != dgShowName.Length )
throw new ArgumentException( "dbColName.Length != dgShowName.Length" );
DataGridTableStyle dgts = new DataGridTableStyle();
dgts.MappingName = tableMappingName;
DataGridColumnStyle dgcs = null;
for ( int i=0; i<dbColName.Length; i++ )
{
if ( InArray( boolColumnIndex, i ) )
dgcs = new DataGridBoolColumn ();
else
dgcs = new DataGridTextBoxColumn();
if ( columnWidth != null && i < columnWidth.Length )
{
dgcs.Width = columnWidth[ i ];
}
dgcs.MappingName = dbColName[i];
dgcs.HeaderText = dgShowName[i];
dgts.GridColumnStyles.Add( dgcs );
}
return dgts;
}
示例12: TestAllowSortingChangedEvent_default
public void TestAllowSortingChangedEvent_default ()
{
DataGridTableStyle dg = new DataGridTableStyle (true);
eventhandled = false;
dg.AllowSortingChanged += new EventHandler (OnEventHandler);
dg.AllowSorting = !dg.AllowSorting;
Assert.AreEqual (true, eventhandled, "A2");
}
示例13: TestAlternatingBackColorChangedEvent
public void TestAlternatingBackColorChangedEvent ()
{
DataGridTableStyle dg = new DataGridTableStyle ();
eventhandled = false;
dg.AlternatingBackColorChanged += new EventHandler (OnEventHandler);
dg.AlternatingBackColor = Color.Red;
Assert.AreEqual (true, eventhandled, "A1");
}
示例14: SizeColumnsToContent
public void SizeColumnsToContent(DataGrid dataGrid)
{
Graphics Graphics = dataGrid.CreateGraphics();
DataGridTableStyle tableStyle = new DataGridTableStyle();
DataTable dataTable = (DataTable)dataGrid.DataSource;
dataGrid.TableStyles.Clear();
tableStyle.MappingName = dataTable.TableName;
DataGridTextBoxColumn columnStyle;
DataColumn dataColumn = dataTable.Columns[0];
columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = dataColumn.ColumnName;
columnStyle.MappingName = dataColumn.ColumnName;
columnStyle.Width = 30;
tableStyle.GridColumnStyles.Add(columnStyle);
dataColumn = dataTable.Columns[1];
columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = dataColumn.ColumnName;
columnStyle.MappingName = dataColumn.ColumnName;
columnStyle.Width = 60;
tableStyle.GridColumnStyles.Add(columnStyle);
dataColumn = dataTable.Columns[2];
columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = dataColumn.ColumnName;
columnStyle.MappingName = dataColumn.ColumnName;
columnStyle.Width = 60;
tableStyle.GridColumnStyles.Add(columnStyle);
dataColumn = dataTable.Columns[3];
columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = dataColumn.ColumnName;
columnStyle.MappingName = dataColumn.ColumnName;
columnStyle.Width = 60;
tableStyle.GridColumnStyles.Add(columnStyle);
dataColumn = dataTable.Columns[4];
columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = dataColumn.ColumnName;
columnStyle.MappingName = dataColumn.ColumnName;
columnStyle.Width = 60;
tableStyle.GridColumnStyles.Add(columnStyle);
dataColumn = dataTable.Columns[5];
columnStyle = new DataGridTextBoxColumn();
columnStyle.HeaderText = dataColumn.ColumnName;
columnStyle.MappingName = dataColumn.ColumnName;
columnStyle.Width = 40;
tableStyle.GridColumnStyles.Add(columnStyle);
dataGrid.TableStyles.Add(tableStyle);
Graphics.Dispose();
}
示例15: FormSTO_Load
private void FormSTO_Load(object sender, EventArgs e)
{
buttonConvert.Hide();
try
{
SqlDataReader dr;
string sqls = "SELECT COUNT(TagID),COUNT([TagDuplicate]),COUNT(*) FROM MasterKanban";
SqlCommand cmd = new SqlCommand(sqls, Connect.con2);
if (Connect.con2.State == ConnectionState.Closed) { Connect.con2.Open(); }
dr = cmd.ExecuteReader();
if (dr.Read())
{
labelUniq.Text = "Uniq Item : " + dr[0].ToString();
labelDuplicate.Text = "Duplicate Item : " + dr[1].ToString();
labelTotal.Text = "Total Scan Item : " + dr[2].ToString();
}
dr.Close();
cmd.Dispose();
if (Connect.con2.State == ConnectionState.Open) { Connect.con2.Close(); }
DataSet ds = new DataSet();
string strSQL = " select distinct(TagDuplicate), count(TagDuplicate) as Jumlah from MasterKanban where TagDuplicate is not null group by TagDuplicate";
SqlDataAdapter da = new SqlDataAdapter(strSQL, Connect.con2);
da.Fill(ds, "LogDuplicat");
dataGridListDuplicat.DataSource = ds.Tables[0];
DataGridTableStyle ts = new DataGridTableStyle();
dataGridListDuplicat.TableStyles.Clear();
ts.MappingName = "LogDuplicat";
DataGridTextBoxColumn col1 = new DataGridTextBoxColumn();
col1.HeaderText = "TagDuplicate";
col1.MappingName = "TagDuplicate";
col1.Width = 190;
ts.GridColumnStyles.Add(col1);
DataGridTextBoxColumn col2 = new DataGridTextBoxColumn();
col2.HeaderText = "Jumlah";
col2.MappingName = "Jumlah";
col2.Width = 40;
ts.GridColumnStyles.Add(col2);
dataGridListDuplicat.TableStyles.Add(ts);
dataGridListDuplicat.Refresh();
ds.Tables.Clear();
da.Dispose();
ds.Dispose();
dataGridListDuplicat.Enabled = true;
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
this.Close();
}
}