This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
MyPopupColorPickEditForm.cs
78 lines (72 loc) · 2.78 KB
/
MyPopupColorPickEditForm.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
70
71
72
73
74
75
76
77
78
// Developer Express Code Central Example:
// How to add a Clear button to implement a clear edit value functionality
//
// This example demonstrates how to add a Clear button to the ColorPickEdit
// dropdown form to implement a clear edit value functionality.
// For this, add the
// ShowClear property to the RepositoryItemMyColorPickEdit class, create a
// SimpleButton, and add it to the Control collection of the dropdown form. The
// ShowClear property specifies the visibility of the Clear button in the dropdown
// form. If the value is true, the dropdown form contains a Clear button;
// otherwise, false. The default is true. The Clear button allows end-users to
// clear the currently selected color. Clicking the button assigns the null value
// to the edit value and closes the dropdown. You can use this approach both in
// inplace and standalone modes.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E4943
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Q535402 {
public class MyPopupColorPickEditForm : PopupColorPickEditForm {
private SimpleButton fClearButton;
public int ClearBtnHeight {
get {
return fClearButton.Height;
}
}
public bool ShowClear {
get {
var properties = (RepositoryItemMyColorPickEdit)(OwnerEdit.Properties);
return properties.ShowClear;
}
}
public MyPopupColorPickEditForm(ColorEdit ownerEdit)
: base(ownerEdit) {
Controls.Add(GetClearButton());
}
protected override DevExpress.XtraEditors.Popup.PopupBaseFormViewInfo CreateViewInfo() {
return new MyPopupBaseFormViewInfo(this);
}
protected override void OnBeforeShowPopup() {
base.OnBeforeShowPopup();
if (ShowClear) {
fClearButton.Visible = ShowClear;
}
}
private Control GetClearButton() {
fClearButton = new SimpleButton() {
Text = "Clear",
Dock = DockStyle.Bottom
};
fClearButton.Click += clearButton_Click;
return fClearButton;
}
private void clearButton_Click(object sender, EventArgs e) {
if (!ShowClear) {
return;
}
OwnerEdit.EditValue = null;
Close();
}
public override System.Drawing.Size CalcFormSize(System.Drawing.Size contentSize) {
if (ShowClear) {
contentSize.Height += ClearBtnHeight;
}
return base.CalcFormSize(contentSize);
}
}
}