- 积分
- 352
- 在线时间
- 183 小时
- 主题
- 22
- 注册时间
- 2016-9-10
- 帖子
- 142
- 最后登录
- 2022-9-21
- 帖子
- 142
- 软币
- 1717
- 在线时间
- 183 小时
- 注册时间
- 2016-9-10
|
本帖最后由 1002068421 于 2018-5-24 09:59 编辑
固定列在哪里
设置Columns,选择要固定的列。设置Fixed属性,可以选择:固定在左边、固定在右边、不固定。
按图片选好按钮,然后设置Buttons下的属性 Kind = ButtonPredefines.Glyph;//初始的是有一个按钮
Caption = str[0];
Appearance.Options.UseForeColor = true;
Appearance.ForeColor = Color.Pink;
和选择的按钮属性
btn.ButtonsStyle = BorderStyles.Default;
btn.TextEditStyle = TextEditStyles.HideTextEditor;
也可以自定义按钮
private RepositoryItemButtonEdit m_HandleBtn = new RepositoryItemButtonEdit();
初始化的时候设置按钮
List<string> str = new List<string>() { "查看资料", "处理" };
SetEditBtn(m_HandleBtn, str);
private void SetEditBtn(RepositoryItemButtonEdit btn, List<string> str)
{
for (int i = 0; i < str.Count(); i++)
{
btn.Buttons[0].Kind = ButtonPredefines.Glyph;//初始的是有一个按钮
btn.Buttons[0].Caption = str[0];
btn.Buttons[0].Appearance.Options.UseForeColor = true;
btn.Buttons[0].Appearance.ForeColor = Color.Pink;
if (i > 0)
{
btn.Buttons.Add(new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph
, str, -1, true, true, false, DevExpress.XtraEditors.ImageLocation.MiddleCenter, null
, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None)
, new DevExpress.Utils.SerializableAppearanceObject() { ForeColor = Color.Blue, Options = { UseBorderColor = true } }
, "", null, null, true));
}
// btn.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
//new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph
// , "查看资料", -1, true, true, false, DevExpress.XtraEditors.ImageLocation.MiddleCenter, null
// , new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None)
// , new DevExpress.Utils.SerializableAppearanceObject(), "", null, null, true),
//new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph
// , "处理", -1, true, true, false, DevExpress.XtraEditors.ImageLocation.MiddleCenter, null
// , new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None)
// , new DevExpress.Utils.SerializableAppearanceObject(), "", null, null, true)});
}
btn.ButtonsStyle = BorderStyles.Default;
btn.TextEditStyle = TextEditStyles.HideTextEditor;
}
然后在事件添加按钮到表格
private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
{
if (e.RowHandle >= 0)
{
if (e.Column.FieldName == "HandleBtn")
{
e.RepositoryItem = m_HandleBtn;
}
}
//if (e.Column.FieldName == "LookBtn")
//{
// e.RepositoryItem = m_LookBtn;
//}
}
最后是注册按钮事件
this.m_HandleBtn.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(dgvBtns);
private void dgvBtns(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
var SelectdeRow = gridView1.GetRow(gridView1.FocusedRowHandle) as system_oa_client_rec_error;
if (SelectdeRow == null)
return;
if (e.Button.Index == 0)
{
//方法
}
if (e.Button.Index == 1)
{
//方法
}
}
最后一张图是效果图
|
-
选择buttonedit按钮
-
|