public void BindComboBox(object obj, List <HR_EmployeeResult> empList) { if (obj is Controls.UcComboBox) { Controls.UcComboBox c = obj as Controls.UcComboBox; c.ValueMember = "EmpID"; c.DisplayMember = "EmpName"; c.DataSource = empList; } else if (obj is DataGridViewComboBoxColumn) { DataGridViewComboBoxColumn c = obj as DataGridViewComboBoxColumn; c.ValueMember = "EmpID"; c.DisplayMember = "EmpName"; c.DataSource = empList; } else if (obj is DataGridViewComboBoxExColumn) { DataGridViewComboBoxExColumn c = obj as DataGridViewComboBoxExColumn; c.ValueMember = "EmpID"; c.DisplayMember = "EmpName"; c.DataSource = empList; } else if (obj is GridComboBoxExEditControl) { GridComboBoxExEditControl c = obj as GridComboBoxExEditControl; c.ValueMember = "EmpID"; c.DisplayMember = "EmpName"; c.DataSource = empList; } }
/// <summary> /// Launches a "clip" comboBox to let the user select the /// cell clip. It does this by temporarily setting the /// appropriate cell-level EditorType - and resets it when /// editing is complete. /// </summary> /// <param name="e"></param> private void LaunchCombo(KeyEventArgs e) { // Set a new cell-level EditorType, and initialize // the combo dropdown with the available audio clips EditorCell.EditorType = typeof(MyGridComboBoxExEditControl); GridComboBoxExEditControl cb = EditorCell.EditControl as GridComboBoxExEditControl; if (cb != null) { cb.DisableInternalDrawing = true; cb.DropDownStyle = ComboBoxStyle.DropDownList; foreach (string clip in _Clips) { cb.Items.Add(clip); } cb.DrawItem += GridClipControlDrawItem; } // Deactivate the current active editor, and initiate // an edit session on the newly set modal combo editor. EditorCell.SuperGrid.DeactivateNonModalEditor(); EditorCell.BeginEdit(true, e); }
private void InitializeCombo() { GridPanel panel = superGridControl1.PrimaryGrid; GridComboBoxExEditControl cbx = panel.Columns["ComboBoxEx"].EditControl as GridComboBoxExEditControl; if (cbx != null) { cbx.Items.AddRange(_Gems); } }
private void FrmConfigSet_Load(object sender, EventArgs e) { superGridControl1.PrimaryGrid.AutoGenerateColumns = false; txtCommonAppConfig.Text = this._CommonAppConfig.AppIdentifier; intIptSynchInterval.Value = this._CommonAppConfig.SynchInterval; chkStartup.Checked = this._CommonAppConfig.Startup; txtServerConnStr.Text = this._CommonAppConfig.ServerConnStr; txtClientConnStr.Text = this._CommonAppConfig.ClientConnStr; GridComboBoxExEditControl control = superGridControl1.PrimaryGrid.Columns["SynchType"].EditControl as GridComboBoxExEditControl; BindGridCombox(control, new List <string>() { "上传", "下达", "双向" }); superGridControl1.PrimaryGrid.DataSource = this._CommonAppConfig.TableSynchs; }
public static bool SetMEPanelData(Com_PartOperation comPartOperation, string cus, string partNo, string cusVer, string opVer, string op1, ref GridPanel MEPanel) { try { Com_MEMain comMEMain1 = new Com_MEMain(); IList <Com_Dimension> listComDimension1 = new List <Com_Dimension>(); CaxSQL.GetCom_MEMain(comPartOperation, out comMEMain1); CaxSQL.GetListCom_Dimension(comMEMain1, out listComDimension1); //Com_MEMain comMEMain = session.QueryOver<Com_MEMain>() // .Where(x => x.comPartOperation == comPartOperation).SingleOrDefault<Com_MEMain>(); //IList<Com_Dimension> listComDimension = session.QueryOver<Com_Dimension>() // .Where(x => x.comMEMain == comMEMain).List<Com_Dimension>(); int MECount = -1; foreach (Com_Dimension i in listComDimension1) { //2017.02.14判斷是否已經有插入過 bool IsExist = false; for (int y = 0; y < MEPanel.Rows.Count; y++) { if (i.excelType == MEPanel.GetCell(y, 1).Value.ToString()) { IsExist = true; } } if (IsExist) { continue; } MECount++; //由excelType取得廠區專用的Excel路徑 List <string> ExcelData = new List <string>(); status = GetExcelForm.GetMEExcelForm(i.excelType, out ExcelData); if (!status) { return(false); } object[] o = new object[] { false, i.excelType, i.draftingVer, "" , string.Format("{0}_{1}_{2}資料夾" , partNo , cusVer , opVer) }; MEPanel.Rows.Add(new GridRow(o)); MEPanel.GetCell(MECount, 0).Value = false; MEPanel.GetCell(MECount, 3).EditorType = typeof(GridComboBoxExEditControl); GridComboBoxExEditControl singleCell = MEPanel.GetCell(MECount, 3).EditControl as GridComboBoxExEditControl; //singleCell.Items.Add(""); foreach (string tempStr in ExcelData) { singleCell.Items.Add(tempStr); } if (singleCell.Items.Count == 1) { MEPanel.GetCell(MECount, 3).Value = singleCell.Items[0].ToString(); } else { MEPanel.GetCell(MECount, 3).Value = "(雙擊)選擇表單"; } } #region 找OIS資料夾,並插入Panel string OISFolderPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}\{6}", OutputForm.EnvVariables.env_Task, cus, partNo, cusVer, opVer, "OP" + op1, "OIS"); //string OISFolderPath = string.Format(@"{0}\{1}\{2}\{3}\{4}\{5}\{6}", CaxEnv.GetGlobaltekEnvDir() + "\\Task", cus, partNo, cusVer, opVer, "OP" + op1, "OIS"); string[] OISFolder = Directory.GetFileSystemEntries(OISFolderPath, "*.pdf"); foreach (string item in OISFolder) { if (!item.Contains(".pdf")) { continue; } MECount++; object[] o = new object[] { false, "PDF", Path.GetFileNameWithoutExtension(item), "", string.Format("{0}_{1}_{2}資料夾", partNo, cusVer, opVer) }; MEPanel.Rows.Add(new GridRow(o)); } #endregion } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); return(false); } return(true); }
public void BindComboBox(object obj, string itemCode, List <SYS_DictItemLineResult> rst) { DataValueType valueType = DataValueType.String; if (obj is Controls.UcComboBox) { Controls.UcComboBox c = obj as Controls.UcComboBox; if (c != null && !string.IsNullOrEmpty(itemCode)) { List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >(); List <SYS_DictItemLineResult> list = rst.Where(a => a.ItemCode == itemCode).ToList(); if (list != null && list.Count > 0) { kvList = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList(); valueType = list[0].ValueType; } kvList.Insert(0, new KeyValuePair <string, object>("", "")); c.ValueMember = "Value"; c.DisplayMember = "Key"; if (valueType == DataValueType.Int32) { c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList(); } else if (valueType == DataValueType.Decimal) { c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == ""?null:(decimal?)a.Value.ToDecimal()))).ToList(); } else if (valueType == DataValueType.Boolean) { c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == ""?null:(bool?)a.Value.ToBooleanHasNull()))).ToList(); } else { c.DataSource = kvList; } } } else if (obj is DataGridViewComboBoxColumn) { DataGridViewComboBoxColumn c = obj as DataGridViewComboBoxColumn; if (c != null && !string.IsNullOrEmpty(itemCode)) { List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >(); List <SYS_DictItemLineResult> list = rst.Where(a => a.ItemCode == itemCode).ToList(); if (list != null && list.Count > 0) { kvList = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList(); valueType = list[0].ValueType; } kvList.Insert(0, new KeyValuePair <string, object>("", "")); c.ValueMember = "Value"; c.DisplayMember = "Key"; if (valueType == DataValueType.Int32) { c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList(); } else if (valueType == DataValueType.Decimal) { c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (decimal?)a.Value.ToDecimal()))).ToList(); } else if (valueType == DataValueType.Boolean) { c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (bool?)a.Value.ToBooleanHasNull()))).ToList(); } else { c.DataSource = kvList; } } } else if (obj is DataGridViewComboBoxExColumn) { DataGridViewComboBoxExColumn c = obj as DataGridViewComboBoxExColumn; if (c != null && !string.IsNullOrEmpty(itemCode)) { List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >(); List <SYS_DictItemLineResult> list = rst.Where(a => a.ItemCode == itemCode).ToList(); if (list != null && list.Count > 0) { kvList = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList(); valueType = list[0].ValueType; } kvList.Insert(0, new KeyValuePair <string, object>("", "")); c.ValueMember = "Value"; c.DisplayMember = "Key"; if (valueType == DataValueType.Int32) { c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList(); } else if (valueType == DataValueType.Decimal) { c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (decimal?)a.Value.ToDecimal()))).ToList(); } else if (valueType == DataValueType.Boolean) { c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (bool?)a.Value.ToBooleanHasNull()))).ToList(); } else { c.DataSource = kvList; } } } else if (obj is GridComboBoxExEditControl) { GridComboBoxExEditControl c = obj as GridComboBoxExEditControl; if (c != null && !string.IsNullOrEmpty(itemCode)) { List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >(); List <SYS_DictItemLineResult> list = rst.Where(a => a.ItemCode == itemCode).ToList(); if (list != null && list.Count > 0) { kvList = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList(); valueType = list[0].ValueType; } kvList.Insert(0, new KeyValuePair <string, object>("", "")); c.ValueMember = "Value"; c.DisplayMember = "Key"; if (valueType == DataValueType.Int32) { c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList(); } else if (valueType == DataValueType.Decimal) { c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (decimal?)a.Value.ToDecimal()))).ToList(); } else if (valueType == DataValueType.Boolean) { c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (bool?)a.Value.ToBooleanHasNull()))).ToList(); } else { c.DataSource = kvList; } } } }
/// <summary> /// 绑定Grid下拉列表 /// </summary> /// <param name="control"></param> /// <param name="list"></param> private void BindGridCombox(GridComboBoxExEditControl control, List <string> list) { control.DataSource = list; }