-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
69 lines (65 loc) · 2.55 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.ViewInfo;
using DevExpress.XtraEditors.Controls;
using System.Reflection;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraEditors.Repository;
namespace SingleButtonClick
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 3; i++)
dataTable1.Rows.Add(new object[] { i, "Name" + i });
}
private void gridView1_MouseDown(object sender, MouseEventArgs e)
{
if ((Control.ModifierKeys & Keys.Control) != Keys.Control)
{
GridView view = sender as GridView;
GridHitInfo hi = view.CalcHitInfo(e.Location);
if (hi.InRowCell)
{
if (hi.Column.RealColumnEdit.GetType() == typeof(RepositoryItemComboBox))
{
view.FocusedRowHandle = hi.RowHandle;
view.FocusedColumn = hi.Column;
view.ShowEditor();
//force button click
ButtonEdit edit = (view.ActiveEditor as ComboBoxEdit);
Point p = view.GridControl.PointToScreen(e.Location);
p = edit.PointToClient(p);
EditHitInfo ehi = (edit.GetViewInfo() as ButtonEditViewInfo).CalcHitInfo(p);
if (ehi.HitTest == EditHitTest.Button)
{
((ComboBoxEdit)view.ActiveEditor).ShowPopup();
PerformClick(edit, new ButtonPressedEventArgs(ehi.HitObject as EditorButton));
((DevExpress.Utils.DXMouseEventArgs)e).Handled = true;
}
}
}
}
}
void PerformClick(ButtonEdit editor, ButtonPressedEventArgs e)
{
if (editor == null || e == null) return;
MethodInfo mi = typeof(RepositoryItemButtonEdit).GetMethod("RaiseButtonClick",
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
if (mi != null)
mi.Invoke(editor.Properties, new object[] { e });
}
}
}