本文整理汇总了C#中System.Windows.Forms.DataGridViewCheckBoxCell类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewCheckBoxCell类的具体用法?C# DataGridViewCheckBoxCell怎么用?C# DataGridViewCheckBoxCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewCheckBoxCell类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewCheckBoxCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Defaults
public void Defaults ()
{
DataGridViewCheckBoxCell cell = new DataGridViewCheckBoxCell ();
Assert.AreEqual (null, cell.EditedFormattedValue, "A1");
Assert.AreEqual (false, cell.EditingCellValueChanged, "A2");
Assert.AreEqual (null, cell.EditType, "A3");
Assert.AreEqual (null, cell.FalseValue, "A4");
Assert.AreEqual (typeof (bool), cell.FormattedValueType, "A5");
Assert.AreEqual (null, cell.IndeterminateValue, "A6");
Assert.AreEqual (false, cell.ThreeState, "A7");
Assert.AreEqual (null, cell.TrueValue, "A8");
Assert.AreEqual (typeof (bool), cell.ValueType, "A9");
Assert.AreEqual ("DataGridViewCheckBoxCell { ColumnIndex=-1, RowIndex=-1 }", cell.ToString (), "A10");
cell.ThreeState = true;
Assert.AreEqual (null, cell.EditedFormattedValue, "A11");
Assert.AreEqual (false, cell.EditingCellValueChanged, "A12");
Assert.AreEqual (null, cell.EditType, "A13");
Assert.AreEqual (null, cell.FalseValue, "A14");
Assert.AreEqual (typeof (CheckState), cell.FormattedValueType, "A15");
Assert.AreEqual (null, cell.IndeterminateValue, "A16");
Assert.AreEqual (true, cell.ThreeState, "A17");
Assert.AreEqual (null, cell.TrueValue, "A18");
Assert.AreEqual (typeof (CheckState), cell.ValueType, "A19");
}
示例2: dtgComandos_CellClick
private void dtgComandos_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0 && e.RowIndex == -1)
{
chkTodos.Checked = !chkTodos.Checked;
chkTodos_Click(chkTodos, null);
}
else if (e.ColumnIndex == 0 && e.RowIndex > -1)
{
DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell();
ch1 = (DataGridViewCheckBoxCell)dtgComandos.Rows[dtgComandos.CurrentRow.Index].Cells[0];
if (ch1.Value == null)
ch1.Value = false;
switch (ch1.Value.ToString())
{
case "True":
ch1.Value = false;
break;
case "False":
ch1.Value = true;
break;
}
chkTodos.CheckState = StatusComandos();
}
}
示例3: LoadDetail
public override void LoadDetail()
{
lblTableName.Text = "";
//lblTableDBDesc.Text = "";//db_desc
//lblTableLocalDesc.Text = "";//local_desc
txtTableNewDesc.Text = "";//new_desc
dgvSchema.Rows.Clear();
this.node = App.Instance.SelectedNode;
this.view = App.Instance.SelectedNode.Tag as IViewInfo;
if (this.view != null)
{
lblTableName.Text = this.view.RawName;
//lblTableDBDesc.Text = this.view.Description;//db_desc
//lblTableLocalDesc.Text = this.view.Attributes.ContainsKey("local_desc") ? this.view.Attributes["local_desc"] : "";//local_desc
//txtTableNewDesc.Text = this.view.Attributes.ContainsKey("new_desc") ? this.view.Attributes["new_desc"] : "";//new_desc
txtTableNewDesc.Text = this.view["local_desc"] ?? "";//local_desc
//foreach (var item in this.view.Columns)
//{
// int index = dgvSchema.Rows.Add();
// DataGridViewRow row = dgvSchema.Rows[index];
// //row.Tag = item.IsPrimaryKey;
// row.Cells[0].Value = item.RawName;
// row.Cells[1].Value = SQLHelper.GetFullSqlType(item);
// row.Cells[2].Value = item.Nullable ? true : false;
// //row.Cells[3].Value = item.Description;
// //row.Cells[4].Value = item.Attributes.ContainsKey("local_desc") ? item.Attributes["local_desc"] : "";
// //row.Cells[5].Value = item.Attributes.ContainsKey("new_desc") ? item.Attributes["new_desc"] : "";
// row.Cells[3].Value = item["local_desc"] ?? "";
//}
List<DataGridViewRow> rlist = new List<DataGridViewRow>();
foreach (var item in this.view.Columns)
{
DataGridViewTextBoxCell col1 = new DataGridViewTextBoxCell();
col1.Value = item.RawName;
DataGridViewTextBoxCell col2 = new DataGridViewTextBoxCell();
col2.Value = SQLHelper.GetFullSqlType(item);
DataGridViewCheckBoxCell col3 = new DataGridViewCheckBoxCell();
col3.Value = item.Nullable ? true : false;
DataGridViewTextBoxCell col4 = new DataGridViewTextBoxCell();
col4.Value = item["local_desc"] ?? "";
DataGridViewTextBoxCell col5 = new DataGridViewTextBoxCell();
DataGridViewRow row = new DataGridViewRow();
row.Cells.AddRange(new DataGridViewCell[] { col1, col2, col3, col4, col5 });
rlist.Add(row);
}
dgvSchema.Rows.AddRange(rlist.ToArray());
}
}
示例4: Value
public void Value ()
{
DataGridViewCheckBoxCell tbc = new DataGridViewCheckBoxCell ();
Assert.IsNull (tbc.Value, "#1");
tbc.Value = string.Empty;
Assert.AreEqual (string.Empty, tbc.Value, "#2");
tbc.Value = 5;
Assert.AreEqual (5, tbc.Value, "#3");
tbc.Value = null;
Assert.IsNull (tbc.Value, "#4");
}
示例5: AddGenerationParameterAsCheckBox
private void AddGenerationParameterAsCheckBox(String g, bool v)
{
DataGridViewRow r = new DataGridViewRow();
DataGridViewCell rColumn1 = new DataGridViewTextBoxCell();
DataGridViewCell rColumn2 = new DataGridViewCheckBoxCell();
rColumn1.Value = g;
rColumn2.Value = v;
r.Cells.Add(rColumn1);
r.Cells.Add(rColumn2);
generationParametersTable.Rows.Add(r);
}
示例6: Chk_Click
//Fire check checkbox event
private void Chk_Click(object sender, DataGridViewCellEventArgs e)
{
if (I_Table.Columns[e.ColumnIndex].Name == "Chk")
{
DataGridViewCheckBoxCell chk = new DataGridViewCheckBoxCell();
chk = (DataGridViewCheckBoxCell)I_Table.Rows[I_Table.CurrentRow.Index].Cells["Chk"];
chk.Value = !(bool)chk.Value;
}
}
示例7: addRow
public void addRow(DataGridView view, FileDirectory fd, string config)
{
DirectoryDataGridViewRow directoryDataGridViewRow = new DirectoryDataGridViewRow(fd);
string text = DirectoryHandler.getInstance().getPathFromParent(fd, fd.getPath());
DirectoryDataGridViewTextBoxCell directories = new DirectoryDataGridViewTextBoxCell(text);
DataGridViewComboBoxCell commands = new DataGridViewComboBoxCell();
DataGridViewCheckBoxCell include = new DataGridViewCheckBoxCell();
DataGridViewCheckBoxCell echo = new DataGridViewCheckBoxCell();
DataGridViewCheckBoxCell display = new DataGridViewCheckBoxCell();
DataGridViewCheckBoxCell autoExit = new DataGridViewCheckBoxCell();
DataGridViewCheckBoxCell waitForExit = new DataGridViewCheckBoxCell();
if (text.Length > 50)
{
int i = text.Length;
int num = 20;
while (i > 50)
{
i--;
num++;
}
text = text.Substring(0, 5) + "....." + text.Substring(num);
}
directories.Value = text;
foreach(Command c in PreloadedConfigurationGetterService.getInstance().getCommandsFromXMLConfiguration(config)){
commands.Items.Add(c.getName());
}
if(commands.Items.Count == 0) return;
commands.Value = commands.Items[0];
include.Value = true;
echo.Value = true;
display.Value = true;
autoExit.Value = true;
waitForExit.Value = true;
directoryDataGridViewRow.Cells.Add(directories);
directoryDataGridViewRow.Cells.Add(commands);
directoryDataGridViewRow.Cells.Add(include);
directoryDataGridViewRow.Cells.Add(display);
directoryDataGridViewRow.Cells.Add(autoExit);
directoryDataGridViewRow.Cells.Add(waitForExit);
directories.ReadOnly = true;
commands.ReadOnly = false;
include.ReadOnly = false;
echo.ReadOnly = false;
display.ReadOnly = false;
autoExit.ReadOnly = false;
view.Rows.Add(directoryDataGridViewRow);
}
示例8: UpdateDisplay
private void UpdateDisplay()
{
IVIHandler.Reset();
IviHandler = IVIHandler.Instance;
IviHandler.IviConfigStore.Deserialize(IviHandler.IviConfigStore.MasterLocation);
AdapterConfigList.Rows.Clear();
foreach (IIviSoftwareModule2 SoftwareModule in IviHandler.IviConfigStore.SoftwareModules)
{
if (!SoftwareModule.Name.StartsWith("nis"))
{
DataGridViewRow Row = new DataGridViewRow();
DataGridViewCheckBoxCell UpdateCheckBox = new DataGridViewCheckBoxCell();
DataGridViewTextBoxCell SoftwareModuleTextBox = new DataGridViewTextBoxCell();
DataGridViewTextBoxCell CurrentAdapterClassTextBox = new DataGridViewTextBoxCell();
DataGridViewComboBoxCell NewAdapterClassComboBox = new DataGridViewComboBoxCell();
UpdateCheckBox.Value = false;
SoftwareModuleTextBox.Value = SoftwareModule.Name;
string className = SoftwareModule.AssemblyQualifiedClassName;
if (!className.Equals(string.Empty))
{
Type type = Type.GetType(SoftwareModule.AssemblyQualifiedClassName);
if (type != null)
{
CurrentAdapterClassTextBox.Value = type.Name;
}
}
NewAdapterClassComboBox.Items.Add(string.Empty);
NewAdapterClassComboBox.Items.AddRange(IviCAdapterList);
NewAdapterClassComboBox.Value = NewAdapterClassComboBox.Items[0];
Row.Cells.Add(UpdateCheckBox);
Row.Cells.Add(SoftwareModuleTextBox);
Row.Cells.Add(CurrentAdapterClassTextBox);
Row.Cells.Add(NewAdapterClassComboBox);
AdapterConfigList.Rows.Add(Row);
}
}
}
示例9: FreshDG
private void FreshDG()
{
DG_In.Rows.Clear();
DG_Out.Rows.Clear();
dataset.Clear();
dataset = ServiceContainer.GetService<IGasDAL>().QueryData("EquipName", "EquipTypeSlet");
equipTypeNum = dataset.Tables[0].Rows.Count;
int j = 0;
foreach (DataRow dr in dataset.Tables[0].Rows)
{
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
textboxcell.Value = dataset.Tables[0].Rows[j][0];
row.Cells.Add(textboxcell);
DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
checkcell.Value = false;
row.Cells.Add(checkcell);
DataGridViewTextBoxCell txtboxcell = new DataGridViewTextBoxCell();
row.Cells.Add(txtboxcell);
DG_In.Rows.Add(row);
DataGridViewRow row2 = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell2 = new DataGridViewTextBoxCell();
textboxcell2.Value = dataset.Tables[0].Rows[j][0];
row2.Cells.Add(textboxcell2);
DataGridViewCheckBoxCell checkcell2 = new DataGridViewCheckBoxCell();
checkcell2.Value = false;
row2.Cells.Add(checkcell2);
DataGridViewTextBoxCell txtboxcell2 = new DataGridViewTextBoxCell();
row2.Cells.Add(txtboxcell2);
DG_Out.Rows.Add(row2);
//DataGridViewRow row = new DataGridViewRow();
//row.Cells["设备名称"].Value = dataset.Tables[0].Rows[j][0];//设置row属性
//DG_In.Rows.Add(row);
//DG_Out.Rows.Add(row);
//DG_In.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
//DG_Out.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
j++;
}
}
示例10: CreateCellTemplate
DataGridViewCell CreateCellTemplate(System.Reflection.FieldInfo Info)
{
DataGridViewCell Cell = new DataGridViewTextBoxCell();
Type FieldType = Info.FieldType;
if (FieldType == typeof(bool))
{
Cell = new DataGridViewCheckBoxCell();
}
//else if (FieldType == typeof(Enum))
//{
// Cell = new DataGridViewTextBoxCell();
//}
//else if ( FieldType == typeof(int) || FieldType == typeof(float) || FieldType == typeof(uint) || FieldType == typeof(short) ||
// FieldType == typeof(ushort) || FieldType == typeof(byte) || FieldType == typeof(float))
//{
// Cell = new Datagridview
//}
return Cell;
}
示例11: Clone
public override object Clone()
{
DataGridViewCheckBoxCell cell;
System.Type type = base.GetType();
if (type == cellType)
{
cell = new DataGridViewCheckBoxCell();
}
else
{
cell = (DataGridViewCheckBoxCell) Activator.CreateInstance(type);
}
base.CloneInternal(cell);
cell.ThreeStateInternal = this.ThreeState;
cell.TrueValueInternal = this.TrueValue;
cell.FalseValueInternal = this.FalseValue;
cell.IndeterminateValueInternal = this.IndeterminateValue;
cell.FlatStyleInternal = this.FlatStyle;
return cell;
}
示例12: BindGrid
/*============PrivateFunction=======*/
private void BindGrid()
{
dgvChapterList.AutoGenerateColumns = false;
DataGridViewCell indexCell = new DataGridViewTextBoxCell();
DataGridViewCell chapterTitleCell = new DataGridViewTextBoxCell();
DataGridViewCheckBoxCell hasReadCell = new DataGridViewCheckBoxCell();
DataGridViewTextBoxColumn indexColumn = new DataGridViewTextBoxColumn()
{
CellTemplate = indexCell,
Name = "Index",
HeaderText = "Index",
DataPropertyName = "Index",
Width = 75
};
DataGridViewTextBoxColumn titleColumn = new DataGridViewTextBoxColumn()
{
CellTemplate = indexCell,
Name = "ChapterTitle",
HeaderText = "Chapter Title",
DataPropertyName = "ChapterTitle",
Width = 200
};
DataGridViewCheckBoxColumn makeAudioColumn = new DataGridViewCheckBoxColumn()
{
CellTemplate = hasReadCell,
Name = "Read",
HeaderText = "Read",
DataPropertyName = "Read",
Width = 75,
};
dgvChapterList.Columns.Add(titleColumn);
dgvChapterList.Columns.Add(indexColumn);
dgvChapterList.Columns.Add(makeAudioColumn);
}
示例13: ParametersToDataGridView
public static void ParametersToDataGridView(DataGridView dg,
IEcasParameterized p, IEcasObject objDefaults)
{
if(dg == null) throw new ArgumentNullException("dg");
if(p == null) throw new ArgumentNullException("p");
if(p.Parameters == null) throw new ArgumentException();
if(objDefaults == null) throw new ArgumentNullException("objDefaults");
if(objDefaults.Parameters == null) throw new ArgumentException();
dg.Rows.Clear();
dg.Columns.Clear();
Color clrBack = dg.DefaultCellStyle.BackColor;
Color clrValueBack = dg.DefaultCellStyle.BackColor;
if(clrValueBack.GetBrightness() >= 0.5)
clrValueBack = UIUtil.DarkenColor(clrValueBack, 0.075);
else clrValueBack = UIUtil.LightenColor(clrValueBack, 0.075);
dg.ColumnHeadersVisible = false;
dg.RowHeadersVisible = false;
dg.GridColor = clrBack;
dg.BackgroundColor = clrBack;
dg.DefaultCellStyle.SelectionBackColor = clrBack;
dg.DefaultCellStyle.SelectionForeColor = dg.DefaultCellStyle.ForeColor;
dg.EditMode = DataGridViewEditMode.EditOnEnter;
dg.AllowDrop = false;
dg.AllowUserToAddRows = false;
dg.AllowUserToDeleteRows = false;
dg.AllowUserToOrderColumns = false;
dg.AllowUserToResizeColumns = false;
dg.AllowUserToResizeRows = false;
int nWidth = (dg.ClientSize.Width - UIUtil.GetVScrollBarWidth());
dg.Columns.Add("Name", KPRes.FieldName);
dg.Columns.Add("Value", KPRes.FieldValue);
dg.Columns[0].Width = (nWidth / 2);
dg.Columns[1].Width = (nWidth / 2);
for(int i = 0; i < p.Parameters.Length; ++i)
{
EcasParameter ep = p.Parameters[i];
dg.Rows.Add();
DataGridViewRow row = dg.Rows[dg.Rows.Count - 1];
DataGridViewCellCollection cc = row.Cells;
Debug.Assert(cc.Count == 2);
cc[0].Value = ep.Name;
cc[0].ReadOnly = true;
string strParam = EcasUtil.GetParamString(objDefaults.Parameters, i);
DataGridViewCell c = null;
switch(ep.Type)
{
case EcasValueType.String:
c = new DataGridViewTextBoxCell();
c.Value = strParam;
break;
case EcasValueType.Bool:
c = new DataGridViewCheckBoxCell(false);
(c as DataGridViewCheckBoxCell).Value =
StrUtil.StringToBool(strParam);
break;
case EcasValueType.EnumStrings:
DataGridViewComboBoxCell cmb = new DataGridViewComboBoxCell();
cmb.Sorted = false;
cmb.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
int iFound = -1;
for(int e = 0; e < ep.EnumValues.ItemCount; ++e)
{
EcasEnumItem eei = ep.EnumValues.Items[e];
cmb.Items.Add(eei.Name);
if(eei.ID.ToString() == strParam) iFound = e;
}
if(iFound >= 0) cmb.Value = ep.EnumValues.Items[iFound].Name;
else if(ep.EnumValues.ItemCount > 0) cmb.Value = ep.EnumValues.Items[0].Name;
else { Debug.Assert(false); }
c = cmb;
break;
case EcasValueType.Int64:
c = new DataGridViewTextBoxCell();
c.Value = FilterTypeI64(strParam);
break;
case EcasValueType.UInt64:
c = new DataGridViewTextBoxCell();
c.Value = FilterTypeU64(strParam);
break;
default:
Debug.Assert(false);
break;
}
if(c != null) cc[1] = c;
cc[1].ReadOnly = false;
//.........这里部分代码省略.........
示例14: FreshDG
private void FreshDG()
{
try
{
DG_In.Rows.Clear();
DG_Out.Rows.Clear();
dataset.Clear();
dataset = ServiceContainer.GetService<IGasDAL>().QueryData("EquipTypeSlet");
equipTypeNum = dataset.Tables[0].Rows.Count;
foreach (DataRow dr in dataset.Tables[0].Rows)
{
if (dr["PorC"].ToString() == "True")
{
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
textboxcell.Value = dr[0];
row.Cells.Add(textboxcell);
DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
checkcell.Value = false;
row.Cells.Add(checkcell);
DataGridViewTextBoxCell txtboxcell = new DataGridViewTextBoxCell();
row.Cells.Add(txtboxcell);
DG_In.Rows.Add(row);
}
else
{
DataGridViewRow row2 = new DataGridViewRow();
DataGridViewTextBoxCell textboxcell2 = new DataGridViewTextBoxCell();
textboxcell2.Value = dr[0];
row2.Cells.Add(textboxcell2);
DataGridViewCheckBoxCell checkcell2 = new DataGridViewCheckBoxCell();
checkcell2.Value = false;
row2.Cells.Add(checkcell2);
DataGridViewTextBoxCell txtboxcell2 = new DataGridViewTextBoxCell();
row2.Cells.Add(txtboxcell2);
DG_Out.Rows.Add(row2);
}
//DataGridViewRow row = new DataGridViewRow();
//row.Cells["设备名称"].Value = dataset.Tables[0].Rows[j][0];//设置row属性
//DG_In.Rows.Add(row);
//DG_Out.Rows.Add(row);
//DG_In.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
//DG_Out.Rows[j].Cells[0].Value = dataset.Tables[0].Rows[j][0];
}
}
catch(Exception ex)
{
Console.WriteLine("查询异常" + ex.Message);
return;
}
}
示例15: CarregaGridViewParametros
private void CarregaGridViewParametros()
{
dgParametros.Rows.Clear();
foreach (var param in _parametros)
{
var row = new DataGridViewRow();
var nome = new DataGridViewTextBoxCell { Value = param.ParameterName };
var valor = new DataGridViewMaskedTextCell { Value = param.ParameterValue };
var defineNull = new DataGridViewCheckBoxCell { Value = param.DefineNull };
var lista = new DataGridViewComboBoxCell { DataSource = _tiposDadosParametros, DisplayMember = "Key", ValueMember = "Value", Value = "System.Object|" };
row.Cells.Add(nome);
row.Cells.Add(defineNull);
row.Cells.Add(lista);
row.Cells.Add(valor);
dgParametros.Rows.Add(row);
}
}