本文整理汇总了C#中System.Windows.Forms.DataGridViewComboBoxCell类的典型用法代码示例。如果您正苦于以下问题:C# DataGridViewComboBoxCell类的具体用法?C# DataGridViewComboBoxCell怎么用?C# DataGridViewComboBoxCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataGridViewComboBoxCell类属于System.Windows.Forms命名空间,在下文中一共展示了DataGridViewComboBoxCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterPropertiesDlg_Load
private void FilterPropertiesDlg_Load(object sender, EventArgs e)
{
// заполняем таблицу
foreach (var item in filter.ColumnFilters.Values.ToList())
{
var row = new DataGridViewRow();
row.Cells.Add(new DataGridViewTextBoxCell { Value = item.PropInfo.Name });
row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Title });
if (item.EnabledValues.Length > 0)
{
var valueCol = new DataGridViewComboBoxCell();
valueCol.Items.AddRange(item.EnabledValues.ToArray());
row.Cells.Add(valueCol);
}
else
row.Cells.Add(new DataGridViewTextBoxCell {Value = item.Value ?? string.Empty});
var criteriasCol = new DataGridViewComboBoxCell();
criteriasCol.Items.AddRange(item.GetStringCriterias());
if (item.Criterias != ColumnFilterCriteria.Нет)
criteriasCol.Value = item.Criterias.ToString();
else
criteriasCol.Value = criteriasCol.Items[0];
row.Cells.Add(criteriasCol);
grid.Rows.Add(row);
}
}
示例2: InitGrid
private void InitGrid(RedComboBox[] comboboxes, RedContext context)
{
foreach(RedComboBox cb in comboboxes)
{
var row = new DataGridViewRow();
var c1 = new DataGridViewTextBoxCell();
c1.Value = cb.Name;
DataGridViewCell c2;
if (cb.query.ToLowerInvariant() == "textedit")
{
c2 = new DataGridViewTextBoxCell();
c2.Value = "";
}
else
{
c2 = new DataGridViewComboBoxCell();
var t = cb.GetValues(context);
foreach (DataRow r in t.Rows)
{
(c2 as DataGridViewComboBoxCell).Items.Add(r[0].ToString());
}
(c2 as DataGridViewComboBoxCell).Value = (c2 as DataGridViewComboBoxCell).Items[0];
}
c2.ReadOnly = false;
row.Cells.Add(c1);
row.Cells.Add(c2);
dataGridView1.Rows.Add(row);
}
}
示例3: 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");
}
}
}
示例4: CreateRow
private DataGridViewRow CreateRow(Item item)
{
var row = new DataGridViewRow();
row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Name });
row.Cells.Add(new DataGridViewButtonCell { Value = "Delete" });
var isInShoppingList = RecipeBooks.Current.IsInShoppingList(item, excludeIfInRecipe: true);
row.Cells.Add(new DataGridViewTextBoxCell
{
Value = isInShoppingList
? RecipeBooks.Current.ShoppingList
.Where(sli => sli.Item.Id == item.Id && sli.Recipe == null)
.Sum(sli => sli.Quantity)
: 1
});
var unitCell = new DataGridViewComboBoxCell { DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing };
unitCell.Items.AddRange(item.UnitType.Units().Select(u => u.GuiInfo().DisplayText).ToArray());
unitCell.Value = item.DefaultBuyUnit.GuiInfo().DisplayText;
row.Cells.Add(unitCell);
row.Cells.Add(new DataGridViewButtonCell { Value = isInShoppingList ? REMOVE_FROM_LIST : ADD_TO_LIST });
row.Cells.Add(new DataGridViewTextBoxCell { Value = item.Id });
return row;
}
示例5: DataGridViewComboBoxColumn
public DataGridViewComboBoxColumn ()
{
CellTemplate = new DataGridViewComboBoxCell();
((DataGridViewComboBoxCell) CellTemplate).OwningColumnTemplate = this;
SortMode = DataGridViewColumnSortMode.NotSortable;
autoComplete = true;
displayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
displayStyleForCurrentCellOnly = false;
}
示例6: SelectElement
void SelectElement(DataGridViewComboBoxCell box, string itemName)
{
if (box.Items.IndexOf(itemName) == -1) {
if (itemName == "Any CPU" && box.Items.IndexOf("AnyCPU") >= 0) {
box.Value = "AnyCPU";
} else {
box.Value = box.Items[0];
}
} else {
box.Value = itemName;
}
}
示例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: BindComboBoxCellDataSource
public static void BindComboBoxCellDataSource(DataGridViewComboBoxCell cell, string[][] dataSource)
{
if (dataSource == null ||
dataSource.Length.Equals(0))
{
cell.DataSource = null;
return;
}
List<DataSourceNode> dataSourceNodeList = BindArrayDataHelper.GetDataSource(dataSource, 0, 1);
cell.DataSource = dataSourceNodeList;
cell.DisplayMember = "Text";
cell.ValueMember = "Value";
}
示例9: AddGenerationParameterAsComboBox
private void AddGenerationParameterAsComboBox(String g, String v, Type t)
{
DataGridViewRow r = new DataGridViewRow();
DataGridViewCell rColumn1 = new DataGridViewTextBoxCell();
DataGridViewComboBoxCell rColumn2 = new DataGridViewComboBoxCell();
rColumn2.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
rColumn1.Value = g;
rColumn2.Items.Clear();
string[] mt = Enum.GetNames(t);
rColumn2.Items.AddRange(mt);
rColumn2.Value = v;
r.Cells.Add(rColumn1);
r.Cells.Add(rColumn2);
generationParametersTable.Rows.Add(r);
}
示例10: FreshDG
private void FreshDG()
{
DataSet datasetAlg = new DataSet();
DG_Forecast.Rows.Clear();
dataset.Clear();
dataset = ServiceContainer.GetService<IGasDAL>().QueryData("EquipName", "EquipTypeSlet");
int j = 0;
foreach (DataRow dr in dataset.Tables[0].Rows)
{
DataGridViewRow row = new DataGridViewRow();
DataGridViewTextBoxCell txtboxcell0 = new DataGridViewTextBoxCell();
txtboxcell0.Value = dataset.Tables[0].Rows[j]["EquipName"];
row.Cells.Add(txtboxcell0);
DataGridViewComboBoxCell comboxcell = new DataGridViewComboBoxCell();
datasetAlg = ServiceContainer.GetService<IGasDAL>().QueryData("EquipAlgSlet", "EquipName", dataset.Tables[0].Rows[j]["EquipName"].ToString());
int i = 0;
foreach (DataRow dr2 in datasetAlg.Tables[0].Rows)
{
comboxcell.Items.Add(datasetAlg.Tables[0].Rows[i]["AlgName"]);
i++;
}
row.Cells.Add(comboxcell);
//comboxcell.DisplayMember=;
DataGridViewComboBoxCell comboxcel2 = new DataGridViewComboBoxCell();
comboxcel2.Items.Add("5");
comboxcel2.Items.Add("10");
row.Cells.Add(comboxcel2);
comboxcel2.Value = "10";
DataGridViewComboBoxCell comboxcel3 = new DataGridViewComboBoxCell();
comboxcel3.Items.Add("15");
comboxcel3.Items.Add("30");
comboxcel3.Items.Add("60");
row.Cells.Add(comboxcel3);
comboxcel3.Value = "30";
DG_Forecast.Rows.Add(row);
j++;
}
}
示例11: CreaColumna
public void CreaColumna(string NameColumna,string HeaderColumna)
{
DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
column.Name = NameColumna;
column.HeaderText = HeaderColumna;
//DataGridViewCell cell = new DataGridViewTextBoxCell();
DataGridViewCell cell = new DataGridViewComboBoxCell();
cell.Style.BackColor = Color.White;
column.CellTemplate = cell;
column.FlatStyle = FlatStyle.Popup;
dataGridView1.Columns.Add(column);
if (NameColumna == "NewPuesto")
cargaPuestos(column);
else if (NameColumna == "Rancho")
cargaRancho(column);
else
column.Items.AddRange("P", "E", "J", "EX");
}
示例12: 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);
}
}
}
示例13: setData
public void setData(oFunction functionBase, oSingleData measuredData)
{
this.functionBase = functionBase;
this.measuredData = measuredData;
if (functionBase == null)
{
this.Rows.Clear();
return;
}
this.argumentClasses = functionBase.getArgumentList();
// Cleanup this datagridview)
this.Rows.Clear();
// Build the combobox selection options
string[] options = Enum.GetNames(typeof(DISPLAY_TYPE));
// Fill out this datagridview based on the supplied data
ARGUMENT_STRING_COLLECTION stringData = functionBase.getArgumentString(measuredData);
DataGridViewRow[] newRows = new DataGridViewRow[argumentClasses.Count];
for( int i = 0; i < argumentClasses.Count; i++ )
{
// Add this row
newRows[i] = new DataGridViewRow();
// Add the name cell
newRows[i].Cells[newRows[i].Cells.Add(new DataGridViewTextBoxCell())].Value = stringData.names[i];
// Add the type cell combobox
DataGridViewComboBoxCell comboBox = new DataGridViewComboBoxCell();
comboBox.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
comboBox.Value = Enum.GetName(typeof(DISPLAY_TYPE), argumentClasses[i].displayMethod);
comboBox.Items.AddRange(options);
newRows[i].Cells.Add(comboBox);
// Add the value cell
newRows[i].Cells[newRows[i].Cells.Add(new DataGridViewTextBoxCell())].Value = stringData.values[i];
}
// Add the new rows
this.Rows.AddRange(newRows);
}
示例14: RowEditorDlg
public RowEditorDlg(MetaDataRow mdrow)
{
this.mdrow = mdrow;
InitializeComponent();
for (int i = 0; i < mdrow.Parts.Length; i++)
{
DataGridViewRow row = new DataGridViewRow();
row.Cells.Add(new DataGridViewTextBoxCell() { Value = i.ToString() });
row.Cells.Add(new DataGridViewTextBoxCell() { Value = (Convert.ToUInt64(mdrow.Parts[i])).ToString("X" +(Marshal.SizeOf(mdrow.Parts[i]))*2) });
DataGridViewComboBoxCell cbox = new DataGridViewComboBoxCell();
cbox.Items.Add("Byte");
cbox.Items.Add("UInt16");
cbox.Items.Add("UInt32");
cbox.Items.Add("UInt64");
cbox.Value = mdrow.Parts[i].GetType().Name;
row.Cells.Add(cbox);
dataGridView1.Rows.Add(row);
}
}
示例15: ParameterInputForm
public ParameterInputForm(
IEnumerable<string[]> required,
IEnumerable<string[]> optional
)
: this()
{
foreach (string[] a in required) grdParameters.Rows.Add(a[0], a[1]);
foreach (string[] a in optional)
{
string[] options = a[2].Split('|');
grdParameters.Rows.Add(a[0], a[1], a[2]);
if (options.Length > 1)
{
var cbb = new DataGridViewComboBoxCell();
foreach (string o in options) cbb.Items.Add(o);
string s = a[1] ?? "";
if (cbb.Items.Contains(s)) cbb.Value = s;
grdParameters[1, grdParameters.Rows.Count-1] = cbb;
}
}
}