Ich verwende den von Jesper Palm hier geposteten Code: Benutzersteuerelement außerhalb der Formularbegrenzung anzeigen lassen
/// <summary>
/// A simple popup window that can host any System.Windows.Forms.Control
/// </summary>
public class PopupWindow : System.Windows.Forms.ToolStripDropDown
{
private System.Windows.Forms.Control _content;
private System.Windows.Forms.ToolStripControlHost _host;
public PopupWindow(System.Windows.Forms.Control content)
{
//Basic setup...
this.AutoSize = false;
this.DoubleBuffered = true;
this.ResizeRedraw = true;
this._content = content;
this._host = new System.Windows.Forms.ToolStripControlHost(content);
//Positioning and Sizing
this.MinimumSize = content.MinimumSize;
this.MaximumSize = content.Size;
this.Size = content.Size;
content.Location = Point.Empty;
//Add the host to the list
this.Items.Add(this._host);
}
}
Ich habe es in VB übersetzt:
Public Class PopupWindow
Inherits System.Windows.Forms.ToolStripDropDown
Private _content As System.Windows.Forms.Control
Private _host As System.Windows.Forms.ToolStripControlHost
Public Sub New(ByVal content As System.Windows.Forms.Control)
Me.AutoSize = False
Me.DoubleBuffered = True
Me.ResizeRedraw = True
Me._content = content
Me._host = New System.Windows.Forms.ToolStripControlHost(content)
Me.MinimumSize = content.MinimumSize
Me.MaximumSize = content.MaximumSize
Me.Size = content.Size
content.Location = Point.Empty
Me.Items.Add(Me._host)
End Sub
End Class
Es funktioniert hervorragend mit einer PictureBox, die die Informationen anzeigt. Aber aus irgendeinem Grund kann ich die DataGridView nicht bekommen, etwas anzuzeigen, wenn es in dem Popup ist.
Wenn ich das Raster aus dem Popup herausziehe, werden alle Informationen korrekt angezeigt. Wenn ich während der Fehlersuche pausiere, zeigt das Raster an, dass es alle Daten enthält. Es wird nur nichts angezeigt.
Hat jemand eine Idee?