How to set up MultiComboBoxColumn?
2016-05-10 17:08
295 查看
Pls take a look at code below:
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) |
{ |
if (radGridView1.ActiveEditor is RadMultiColumnComboBoxElement) |
{ |
RadMultiColumnComboBoxElement multiComboBoxElement = (RadMultiColumnComboBoxElement)radGridView1.ActiveEditor; |
multiComboBoxElement.EditorControl.MasterGridViewTemplate.AllowAddNewRow = true; |
multiComboBoxElement.EditorControl.MasterGridViewTemplate.AddNewRowPosition = PinnedRowPosition.Top; |
multiComboBoxElement.EditorControl.MasterGridViewTemplate.BestFitColumns(); |
GridViewDataColumn colDetails = new GridViewDataColumn(); |
colDetails.UniqueName = "Details"; |
colDetails.HeaderText = "Details"; |
colDetails.DataType = typeof(string); |
multiComboBoxElement.Columns.Add(colDetails); |
} |
} |
void
radGridView1_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
RadMultiColumnComboBoxElement multiComboElement =
this
.radGridView1.ActiveEditor
as
RadMultiColumnComboBoxElement;
if
(multiComboElement !=
null
)
{
multiComboElement.EditorControl.MasterGridViewTemplate.BestFitColumns();
multiComboElement.DropDownStyle = RadDropDownStyle.DropDown;
multiComboElement.AutoFilter =
true
;
if
(multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Count == 0)
{
FilterExpression autoFilter =
new
FilterExpression(multiComboElement.DisplayMember, FilterExpression.BinaryOperation.AND,
GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName);
autoFilter.Parameters.Add(GridFilterCellElement.ParameterName,
true
);
multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(autoFilter);
}
}
}
List<mast_tbl_Diagnosis> listdiagnosis; GridViewMultiComboBoxColumn col_0; GridViewMultiComboBoxColumn col_1; |
private void CaseSheet_Load(object sender, EventArgs e) |
{ |
// Form Load Event |
col_0 = (GridViewMultiComboBoxColumn)GridCurrentProcedure.MasterGridViewTemplate.Columns[0]; |
col_1 = (GridViewMultiComboBoxColumn)GridCurrentProcedure.MasterGridViewTemplate.Columns[1]; |
listprocedure = objProcedureCodesData.SelectAll().Where(t1 => t1.Deleted == false).ToList(); |
col_0.DataSource = listprocedure; |
col_1.DataSource = listprocedure; |
col_0.DisplayMember = "Proc_Code"; |
col_0.ValueMember = "Proc_Code"; |
col_1.DisplayMember = "Proc_Description"; |
col_1.ValueMember = "Proc_Description"; |
col_0.DropDownStyle = col_1.DropDownStyle = RadDropDownStyle.DropDown; |
} |
private void GridCurrentProcedure_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) |
{ |
if (GridCurrentProcedure.ActiveEditor is RadMultiColumnComboBoxElement) |
{ |
RadMultiColumnComboBoxElement multiColumnComboElement = (RadMultiColumnComboBoxElement)GridCurrentProcedure.ActiveEditor; |
multiColumnComboElement.AutoSizeDropDownToBestFit = true; |
multiColumnComboElement.AutoFilter = true; |
multiColumnComboElement.DropDownSizingMode = SizingMode.UpDownAndRightBottom; |
if (multiColumnComboElement.Columns.Count > 0) |
return; |
GridViewTextBoxColumn column = new GridViewTextBoxColumn("ID"); |
column.HeaderText = "ID"; |
column.IsVisible = false; |
multiColumnComboElement.Columns.Add(column); |
column = new GridViewTextBoxColumn("Proc_Code"); |
column.HeaderText = "Proc_Code"; |
multiColumnComboElement.Columns.Add(column); |
column = new GridViewTextBoxColumn("Proc_Description"); |
column.HeaderText = "Procedure Description"; |
multiColumnComboElement.Columns.Add(column); |
if (e.ColumnIndex == 0) |
{ |
multiColumnComboElement.SelectedIndexChanged += new EventHandler(ProcCode_multiColumnComboElement_SelectedIndexChanged); |
} |
else |
multiColumnComboElement.SelectedIndexChanged += new EventHandler(ProcDescription_multiColumnComboElement_SelectedIndexChanged); |
} |
} |
private void GridCurrentProcedure_CellEditorInitialized(object sender, GridViewCellEventArgs e) |
{ |
RadMultiColumnComboBoxElement multiComboElement = this.GridCurrentProcedure.ActiveEditor as RadMultiColumnComboBoxElement; |
if (multiComboElement != null) |
{ |
multiComboElement.EditorControl.MasterGridViewTemplate.BestFitColumns(); |
multiComboElement.AutoFilter = true; |
if (multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Count == 0) |
{ |
FilterExpression autoFilter = new FilterExpression("Proc_Code", FilterExpression.BinaryOperation.AND, |
GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName); |
autoFilter.Parameters.Add(GridFilterCellElement.ParameterName, string.Empty); |
multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(autoFilter); |
autoFilter = new FilterExpression("Proc_Description", FilterExpression.BinaryOperation.AND, |
GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName); |
autoFilter.Parameters.Add(GridFilterCellElement.ParameterName, string.Empty); |
multiComboElement.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(autoFilter); |
} |
} |
} |
void ProcCode_multiColumnComboElement_SelectedIndexChanged(object sender, EventArgs e) |
{ |
if (GridCurrentProcedure.ActiveEditor is RadMultiColumnComboBoxElement) |
{ |
RadMultiColumnComboBoxElement multiColumnComboElement = (RadMultiColumnComboBoxElement)GridCurrentProcedure.ActiveEditor; |
multiColumnComboElement.SelectedIndexChanged -= new EventHandler(ProcDescription_multiColumnComboElement_SelectedIndexChanged); |
try |
{ |
GridViewRowInfo row = multiColumnComboElement.EditorControl.CurrentRow; |
if (row != null) |
{ |
GridCurrentProcedure.CurrentRow.Cells[1].Value = row.Cells[2].Value; |
GridCurrentProcedure.CurrentRow.Cells[2].Value = row.Cells[0].Value; |
} |
} |
catch { } |
multiColumnComboElement.SelectedIndexChanged += new EventHandler(ProcDescription_multiColumnComboElement_SelectedIndexChanged); |
} |
} |
void ProcDescription_multiColumnComboElement_SelectedIndexChanged(object sender, EventArgs arg) |
{ |
if (GridCurrentProcedure.ActiveEditor is RadMultiColumnComboBoxElement) |
{ |
RadMultiColumnComboBoxElement multiColumnComboElement = (RadMultiColumnComboBoxElement)GridCurrentProcedure.ActiveEditor; |
multiColumnComboElement.SelectedIndexChanged -= new EventHandler(ProcCode_multiColumnComboElement_SelectedIndexChanged); |
try |
{ |
GridViewRowInfo row = multiColumnComboElement.EditorControl.CurrentRow; |
if (row != null) |
{ |
GridCurrentProcedure.CurrentRow.Cells[0].Value = row.Cells[1].Value; |
GridCurrentProcedure.CurrentRow.Cells[2].Value = row.Cells[0].Value; |
} |
} |
catch { } |
multiColumnComboElement.SelectedIndexChanged += new EventHandler(ProcCode_multiColumnComboElement_SelectedIndexChanged); |
} |
} |
相关文章推荐
- Android4.0 Launcher 源码分析2——Launcher内容加载绑定详细过程
- Android4.0 Launcher 源码分析1——Launcher整体结构
- 第十一周阅读程序(补充)----(3)
- 【Tumload】-tumblr视频下载神器发布啦
- 学习Entity Framework 中的Code First
- 奋斗吧,程序员——第三十四章 挥泪别痴心,只怨情长天未怜【上半部完】
- 在自己应用中打开第三方应用
- 使用Qt Designer创建界面
- ACM必备
- 算法的时间复杂度和空间复杂度分析
- 网站架构
- 图片管理
- ffmpeg-20160510-git-bin
- java 抽象类和接口
- gridView保持间距的已知
- C#的泛型约束-
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
- away3d MaterialBase
- 如何把eclipse的项目托管到github
- C++调用Java