-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomPopupControlContainer.vb
60 lines (49 loc) · 2.39 KB
/
CustomPopupControlContainer.vb
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
Imports DevExpress.XtraBars
Imports DevExpress.XtraBars.Controls
Imports DevExpress.XtraEditors
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Namespace T265126
Friend Class CustomPopupControlContainer
Inherits PopupControlContainer
Public Sub New(ByVal container As IContainer)
MyBase.New(container)
AddHandler Popup, AddressOf CustomPopupControlContainer_Popup
End Sub
Private Sub CustomPopupControlContainer_Popup(ByVal sender As Object, ByVal e As EventArgs)
CreateButton()
End Sub
Private myButton As SimpleButton
Private closeButton As Control
Private _SubControl As PopupContainerBarControl
Private Sub CreateButton()
myButton = New SimpleButton()
myButton.Text = "button"
closeButton = SubControl.Controls(0)
AddHandler closeButton.LocationChanged, AddressOf CloseButton_LocationChanged
myButton.Size = New Size(100, SubControl.Controls(0).Size.Height)
_SubControl = SubControl
_SubControl.Controls.Add(myButton)
AddHandler _SubControl.PaintEx, AddressOf SubControl_PaintEx
End Sub
Private Sub SubControl_PaintEx(ByVal sender As Object, ByVal e As DevExpress.Utils.XtraPaintEventArgs)
Dim barControl As PopupContainerBarControl = TryCast(sender, PopupContainerBarControl)
Dim offsetLocation As Point = New Point(myButton.Location.X + myButton.Width + 3, barControl.CloseButton.Location.Y + 3)
e.Cache.DrawString("Custom string", barControl.Font, Brushes.Red, offsetLocation)
End Sub
Private Sub CloseButton_LocationChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim closeButton As Control = TryCast(sender, Control)
Dim location As Point = closeButton.Location
location.Offset(closeButton.Width + 3, 0)
myButton.Location = location
End Sub
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
RemoveHandler Popup, AddressOf CustomPopupControlContainer_Popup
RemoveHandler closeButton.LocationChanged, AddressOf CloseButton_LocationChanged
RemoveHandler _SubControl.PaintEx, AddressOf SubControl_PaintEx
MyBase.Dispose(disposing)
End Sub
End Class
End Namespace