winform devexpress 用法汇总

时间:2022-01-15 21:49:11

废话不多说先上图

winform devexpress 用法汇总winform devexpress 用法汇总

1.封装分页控件

qrcodeOnPage1.SearchData(gridControl2, IDataPage, sWhere, "", "tb_one");

2.表头带全选按钮(推荐用法)

gridView1.OptionsSelection.MultiSelect = true;
gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
gridView1.OptionsSelection.ShowCheckBoxSelectorInColumnHeader = DevExpress.Utils.DefaultBoolean.True;
this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
this.gridView2.OptionsSelection.EnableAppearanceFocusedCell = false;
        /// <summary>
/// 获取选中的行中指定列的值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void simpleButton3_Click(object sender, EventArgs e)
{
List<string> strList = new List<string>();
for (int i = ; i < this.gridView1.RowCount; i++)
{
if (this.gridView1.IsRowSelected(i))
{
//strList.Add(this.gridView3.GetDataRow(i)[0].ToString());
strList.Add(gridView1.GetRowCellValue(i, "Name").ToString());
MessageBox.Show(gridView1.GetRowCellValue(i, "Name").ToString());
}
}
}

2.1在数据中添加列来完成checkbox的选择(不推荐)

//添加一列
dt.Columns.Add("chk", System.Type.GetType("System.Boolean"));
dt.Columns["chk"].DefaultValue = Boolean.FalseString;
gridControl1.DataSource = dt;

控件中也添加一列同名的列 如图:

winform devexpress 用法汇总