Hi,
I'd like to customize the location of a MessageBox. Ideally, I would just set a parent control and the MessageBox would center itself to the parent.
I tried this ((0,0) to make it obvious) but it doesn't work:
'Dim pt As Point = New Point(Me.Parent.Location.X + Me.Location.X, Me.Parent.Location.Y + Me.Location.Y)
'Telerik.WinControls.RadMessageBox.Instance.Location = New Point((pt.X + Me.Width / 2) - (Telerik.WinControls.RadMessageBox.Instance.Width / 2), (pt.Y + Me.Height / 2))
Telerik.WinControls.RadMessageBox.Instance.Location = New Point(0, 0)
Dim ds As DialogResult = Telerik.WinControls.RadMessageBox.Show(Me, "Are you sure?", "Clear form",
MessageBoxButtons.YesNo, RadMessageIcon.Question,
MessageBoxDefaultButton.Button1)
I've also found this bit of code (modified it according to my needs) from an older answer to someone else's similar question:
Private Sub Instance_LocationChanged(sender As Object, e As EventArgs)
RemoveHandler RadMessageBox.Instance.LocationChanged, AddressOf Instance_LocationChanged
Dim box As RadMessageBoxForm = sender
Dim pt As Point = New Point(Me.Parent.Location.X + Me.Location.X, Me.Parent.Location.Y + Me.Location.Y)
box.Location = New Point((pt.X + Me.Width / 2) - (box.Width / 2), (pt.Y + Me.Height / 2))
AddHandler RadMessageBox.Instance.LocationChanged, AddressOf Instance_LocationChanged
End Sub
But the problem here is that the MessageBox is then static and can't be moved.
Suggestions?
Using version 2021.1.326.40.
Jure