本文整理汇总了C#中System.Windows.Forms.DataGridViewTextBoxCell类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewTextBoxCell类的具体用法?C# DataGridViewTextBoxCell怎么用?C# DataGridViewTextBoxCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewTextBoxCell类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewTextBoxCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindToDgv
void BindToDgv(INewsBase news, int typeID, int pageIndex = 1)
{
dgv.Rows.Clear();
if (news != null)
{
var newsList = news.GetNewsList(typeID, pageIndex);
if (newsList == null || newsList.Count <= 0) return;
foreach (var item in newsList)
{
int index = dgv.Rows.Add();
DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
cell.Value = item.ID;
dgv.Rows[index].Cells["ID"] = cell;
cell = new DataGridViewTextBoxCell();
cell.Value = item.Title;
dgv.Rows[index].Cells["Title"] = cell;
cell = new DataGridViewTextBoxCell();
cell.Value = item.Source;
dgv.Rows[index].Cells["Source"] = cell;
DataGridViewButtonCell cellb = new DataGridViewButtonCell();
cellb.Value = item.IsGetted ? "تامام" : "يىغىش";
dgv.Rows[index].Cells["Make"] = cellb;
dgv.Rows[index].Tag = item;
if (item.IsGetted)
{
dgv.Rows[index].DefaultCellStyle = new DataGridViewCellStyle() { ForeColor = Color.Gray };
}
}
}
}
示例2: btnAddProduct_Click
private void btnAddProduct_Click(object sender, EventArgs e)
{
var af = new AddProductForm();
if (af.ShowDialog() == DialogResult.OK)
{
Product prod=af.Product;
DataGridViewCell cel0 = new DataGridViewTextBoxCell();
cel0.Value = prod.Name;
DataGridViewCell cel1 = new DataGridViewTextBoxCell();
cel1.Value = prod.AlbumName;
DataGridViewCell cel2 = new DataGridViewTextBoxCell();
cel2.Value = prod.Photos.Count;
DataGridViewRow row = new DataGridViewRow();
row.Cells.AddRange(cel0, cel1, cel2);
grid.Rows.Add(row);
Products.Add(prod);
btnStart.Enabled = true;
}
}
示例3: TableForm
public TableForm(string name, IDataReader rdr)
{
DataGridView dgv = new DataGridView();
dgv.Dock = DockStyle.Fill;
DataGridViewTextBoxCell template = new DataGridViewTextBoxCell();
template.Style.Font = new Font("DejaVu Sans",10);
for (int i = 0;i < rdr.FieldCount;i++)
{
DataGridViewColumn col = new DataGridViewColumn(template);
col.Name = rdr.GetName(i);
dgv.Columns.Add(col);
}
while (rdr.Read())
{
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(dgv);
for (int i = 0;i < rdr.FieldCount;i++)
{
object val = rdr[i];
if (val is byte[])
{
val = Encoding.UTF8.GetString((byte[])val);
}
row.Cells[i].Value = val;
}
dgv.Rows.Add(row);
}
Controls.Add(dgv);
}
示例4: InitialDataGridView
public void InitialDataGridView()
{
dataGridView.Rows.Clear();
dataGridView.Columns.Clear();
DataGridViewCell textCell = new DataGridViewTextBoxCell();
DataGridViewColumn timeColumn = new DataGridViewColumn();
timeColumn.HeaderText = "记录时间";
timeColumn.Width = 160;
timeColumn.CellTemplate = textCell;
DataGridViewColumn ipColumn = new DataGridViewColumn();
ipColumn.HeaderText = "IP地址";
ipColumn.Width = 120;
ipColumn.CellTemplate = textCell;
DataGridViewColumn portColumn = new DataGridViewColumn();
portColumn.HeaderText = "端口号";
portColumn.Width = 80;
portColumn.CellTemplate = textCell;
DataGridViewColumn statusColumn = new DataGridViewColumn();
statusColumn.HeaderText = "工作状态";
statusColumn.Width = 180;
statusColumn.CellTemplate = textCell;
dataGridView.Columns.Add(timeColumn);
dataGridView.Columns.Add(ipColumn);
dataGridView.Columns.Add(portColumn);
dataGridView.Columns.Add(statusColumn);
}
示例5: CargarTabla
public void CargarTabla()
{
// Format DataGridView
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.BackgroundColor = this.BackColor;
this.dataGridView1.RowHeadersWidth = 75;
String [] Semana = {"Lunes",
"Martes",
"Miercoles",
"Jueves",
"Viernes",
"Sabado"
};
// Add columns to DataGridView
foreach (String item in Semana)
{
DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
checkColumn.Name = "Columna_" + item;
checkColumn.HeaderText = item;
checkColumn.Width = 75;
checkColumn.ReadOnly = true;
checkColumn.FillWeight = 10; //if the datagridview is resized (on form resize) the checkbox won't take up too much; value is relative to the other columns' fill values
dataGridView1.Columns.Add(checkColumn);
}
// Add rows to DataGridView
for (int i = 7; i <= 32; i++)
{
TimeSpan t = TimeSpan.FromSeconds(25200 + ((i - 7)* 1800));
dataGridView1.Rows.Add();
dataGridView1.Rows[i - 7].HeaderCell.Value = t.ToString().Substring(0, 5) ;
}
// Sabados no se trabaja hasta las 10
for (int i = 0; i < 6; i++)
{
DataGridViewTextBoxCell TextBoxCell = new DataGridViewTextBoxCell();
dataGridView1[5, i] = TextBoxCell;
dataGridView1[5, i].Value = "";
dataGridView1[5, i].Style.BackColor = Color.Black;
dataGridView1[5, i].ReadOnly = true;
}
// Sabados no se trabaja desde las 5
for (int i = 16; i <= 25; i++)
{
DataGridViewTextBoxCell TextBoxCell = new DataGridViewTextBoxCell();
dataGridView1[5, i] = TextBoxCell;
dataGridView1[5, i].Value = "";
dataGridView1[5, i].Style.BackColor = Color.Black;
dataGridView1[5, i].ReadOnly = true;
}
}
示例6: data_grid
public static void data_grid(DataGridView dgv_grid)
{
dgv_grid.AutoGenerateColumns = true;
DataGridViewCell Cell_1 = new DataGridViewTextBoxCell();
DataGridViewCell Cell_2 = new DataGridViewTextBoxCell();
DataGridViewCell Cell_3 = new DataGridViewTextBoxCell();
DataGridViewColumn col__from = new DataGridViewColumn();
DataGridViewColumn col__to = new DataGridViewColumn();
DataGridViewColumn col__length = new DataGridViewColumn();
col__from.HeaderText = "Откуда";
col__to.HeaderText = "Куда";
col__length.HeaderText = "Длина";
col__from.Width = 110;
col__to.Width = 110;
col__length.Width = 110;
col__from.CellTemplate = Cell_1;
col__to.CellTemplate = Cell_2;
col__length.CellTemplate = Cell_3;
dgv_grid.ReadOnly = false;
dgv_grid.AllowUserToAddRows = true;
dgv_grid.AllowUserToDeleteRows = true;
dgv_grid.Columns.Add(col__from);
dgv_grid.Columns.Add(col__to);
dgv_grid.Columns.Add(col__length);
}
示例7: addDirectory
/// <summary>
/// Recursively goes through all files in the directory
/// and adds them to the MyFilesDB
/// </summary>
/// <param name="directory">Current Directory To Search</param>
private void addDirectory(String directory)
{
try
{
foreach (String file in Directory.GetFiles(directory))
{
myFilesDb.AddFile(file);
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell();
cell.Value = "Hashed: " + file;
row.Cells.Add(cell);
if (isShown && !gvLog.IsDisposed && !this.IsDisposed)
{
try
{
this.Invoke(new MethodInvoker(
delegate()
{
gvLog.Rows.Insert(0, row);
}));
}
catch { isShown = false; }
}
}
}
catch { }
foreach (String nextDir in Directory.GetDirectories(directory))
{
addDirectory(nextDir);
}
}
示例8: DisplayConfigs
public void DisplayConfigs()
{
ConfigList.Rows.Clear();
foreach (ConfigSet config in Configs)
{
DataGridViewRow row = new DataGridViewRow();
DataGridViewCell cell = new DataGridViewTextBoxCell();
if (config.DefaultConfig)
cell.Value = @"✔";
else
cell.Value = "";
row.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = config.Name;
row.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = config.BitSize.ToString();
row.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = config.ConfigPath;
row.Cells.Add(cell);
ConfigList.Rows.Add(row);
}
}
示例9: updateGrid
public void updateGrid()
{
dataGridView1.Rows.Clear();
dataGridView1.Columns.Clear();
//style for classroom name
DataGridViewCell cellStyle = new DataGridViewTextBoxCell();
cellStyle.Style.BackColor = Color.Wheat;
DataGridViewButtonColumn deleteButtonColumn = new DataGridViewButtonColumn();
deleteButtonColumn.Text = "Delete Classroom";
deleteButtonColumn.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn updateButtonColumn = new DataGridViewButtonColumn();
updateButtonColumn.Text = "Update Classroom";
updateButtonColumn.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn manageComputersButtonColumn = new DataGridViewButtonColumn();
manageComputersButtonColumn.Text = "Manage computers";
manageComputersButtonColumn.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Add(new DataGridViewColumn(cellStyle));
dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn());
dataGridView1.Columns.Add(updateButtonColumn);
dataGridView1.Columns.Add(manageComputersButtonColumn);
dataGridView1.Columns.Add(deleteButtonColumn);
foreach (Classroom classroom in MainProgram.rooms)
dataGridView1.Rows.Add(classroom.Classroomname,classroom.Projectoravailable);
}
示例10: AddElementToDataGridView
private void AddElementToDataGridView(Param element)
{
var row = new DataGridViewRow();
// пустая сточка означет разделитель между
// отдельными интерфейсами
if(element.ParamName == string.Empty)
{
dataGridView1.Rows.Add(row);
return;
}
// добавляем первую ячейку
var cell1 = new DataGridViewTextBoxCell()
{
Value = element.ParamName + ":"
};
cell1.Style.Font = new Font(dataGridView1.Font, FontStyle.Bold);
row.Cells.Add(cell1);
// добавляем вторую ячейку
var cell2 = new DataGridViewTextBoxCell()
{
Value = element.ParamValue
};
row.Cells.Add(cell2);
// добавляем строчку в dataGridView
dataGridView1.Rows.Add(row);
}
示例11: filldatagrid
public void filldatagrid()
{
computersDataGrid.Rows.Clear();
computersDataGrid.Columns.Clear();
DataGridViewCell cellStyle = new DataGridViewTextBoxCell();
cellStyle.Style.BackColor = Color.Wheat;
DataGridViewButtonColumn deleteButtonColumn = new DataGridViewButtonColumn();
deleteButtonColumn.Text = "Delete Computer";
deleteButtonColumn.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn updateButtonColumn = new DataGridViewButtonColumn();
updateButtonColumn.Text = "Update Computer";
updateButtonColumn.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn viewComputerButtonColumn = new DataGridViewButtonColumn();
viewComputerButtonColumn.Text = "View computer details";
viewComputerButtonColumn.UseColumnTextForButtonValue = true;
DataGridViewButtonColumn moveComputerButtonColumn = new DataGridViewButtonColumn();
moveComputerButtonColumn.Text = "Move computer";
moveComputerButtonColumn.UseColumnTextForButtonValue = true;
computersDataGrid.Columns.Add(new DataGridViewColumn(cellStyle));
computersDataGrid.Columns.Add(updateButtonColumn);
computersDataGrid.Columns.Add(deleteButtonColumn);
computersDataGrid.Columns.Add(viewComputerButtonColumn);
computersDataGrid.Columns.Add(moveComputerButtonColumn);
foreach (Computer comp in classroom.Computersinclassroom)
computersDataGrid.Rows.Add(comp.Computername);
}
示例12: AddItems
private void AddItems(string[] panels, int sections)
{
foreach (string panel in panels)
{
DataGridViewComboBoxCell reff = new DataGridViewComboBoxCell();
DataGridViewTextBoxCell txt2A = new DataGridViewTextBoxCell();
DataGridViewRow dataGridRow = new DataGridViewRow();
//ComboBox reff = new ComboBox();
reff.MaxDropDownItems = sections;
//reff.DataSource =
txt2A.Value = panel;
for (int i = 1; i <= sections; i++)
reff.Items.Add(i);
try
{
dataGridRow.Cells.Add(txt2A);
dataGridRow.Cells.Add(reff);
Grid.Rows.Add(dataGridRow);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error");
}
}
}
示例13: AddToList
void AddToList(CGoodsData pCGoodsData)
{
DataGridViewRow r1 = new DataGridViewRow();
// 상품 시퀀스
DataGridViewTextBoxCell cell_seq = new DataGridViewTextBoxCell();
cell_seq.Value = pCGoodsData.Seq_;
r1.Cells.Add(cell_seq);
// 상품명
DataGridViewTextBoxCell cell_GoodsName = new DataGridViewTextBoxCell();
cell_GoodsName.Value = pCGoodsData.GoodsName_;
r1.Cells.Add(cell_GoodsName);
// 옵션명
DataGridViewTextBoxCell cell_OptionName = new DataGridViewTextBoxCell();
cell_OptionName.Value = pCGoodsData.OptionName_;
r1.Cells.Add(cell_OptionName);
// 채널
DataGridViewTextBoxCell cell_Channel = new DataGridViewTextBoxCell();
cell_Channel.Value = pCGoodsData.ChannelName_;
r1.Cells.Add(cell_Channel);
dataGridView_GoodsList.Rows.Add(r1);
}
示例14: AddFilesToView
public void AddFilesToView(string group)
{
Package p = packages._packages.Find(Package => Package._name == group);
this.form.dataGridView1.BeginInvoke((MethodInvoker)delegate()
{
foreach (Item i in p._items)
{
DataGridViewCellStyle style = new DataGridViewCellStyle();
style.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell filename = new DataGridViewTextBoxCell();
filename.Value = i._file;
row.Cells.Add(filename);
DataGridViewTextBoxCell status = new DataGridViewTextBoxCell();
status.Value = "Unknown";
status.Style = style;
row.Cells.Add(status);
DataGridViewProgressCell download = new DataGridViewProgressCell();
download.Value = 0;
row.Cells.Add(download);
i.row = row;
this.form.dataGridView1.Rows.Add(row);
}
});
}
示例15: SetMatrix
/// <summary>
/// �\���Ώۂ̍s���ݒ肷��D
/// </summary>
/// <param name="m"></param>
public void SetMatrix(KrdLab.Lisys.Matrix m)
{
this.DataGridView.Rows.Clear();
this.DataGridView.Columns.Clear();
if (m == null)
{
return;
}
for (int c = 0; c < m.ColumnSize; ++c)
{
var gridCol = new DataGridViewColumn();
gridCol.HeaderText = String.Format("[ , {0}]", c);
gridCol.ReadOnly = true;
gridCol.SortMode = DataGridViewColumnSortMode.NotSortable;
this.DataGridView.Columns.Add(gridCol);
}
for (int r = 0; r < m.RowSize; ++r)
{
var gridRow = new DataGridViewRow();
gridRow.HeaderCell.Value = String.Format("[{0}, ]", r);
gridRow.ReadOnly = true;
var row = m.Rows[r];
foreach (var v in row)
{
var cell = new DataGridViewTextBoxCell();
cell.Value = v.ToString();
gridRow.Cells.Add(cell);
}
this.DataGridView.Rows.Add(gridRow);
}
this.DataGridView.RowHeadersWidth = 100;
}