G
GodspeedSupreme
Guest
Hi..
I need help with my usercontrol, by adding contextmenustrip in every panel i create. (newpanel)
Public Class Card
Dim panels As New List(Of cardPanel)
Dim x As Integer
Private Sub Panel1_Click(sender As Object, e As EventArgs) Handles Panel1.Click
Dim retString As String = InputBox("Enter Some Info", "Info...", "", -1, -1)
If retString.Trim <> "" Then
Dim p As Panel = DirectCast(sender, Panel)
Dim newPanel As New cardPanel
newPanel.Left = 6
newPanel.Top = If(p.Parent.Controls.OfType(Of cardPanel).Count > 0, p.Parent.Controls.OfType(Of cardPanel).Max(Function(cp) cp.Bottom) + 6, 19)
newPanel.Width = p.Width
newPanel.Height = 36
newPanel.BackColor = Color.White
newPanel.percentage = 0
newPanel.Text = retString
newPanel.Name = "Card" & x.ToString
FlowLayoutCard.Controls.Add(newPanel)
x += 1
AddHandler newPanel.MouseDown, AddressOf childs_MouseDown
Me.FlowLayoutCard.AllowDrop = True
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
Dim p As Panel = DirectCast(sender, Panel)
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
e.Graphics.DrawString("Add card", p.Font, Brushes.Black, New Rectangle(Point.Empty, p.Size), sf)
End Sub
End Class
I need to add a contextmenustrip where I could delete the panels I created:
Something like this :
when I left click the added panel, a contextmenustrip appears "delete" and then when I click the delete, the panel is deleted.
Continue reading...
I need help with my usercontrol, by adding contextmenustrip in every panel i create. (newpanel)
Public Class Card
Dim panels As New List(Of cardPanel)
Dim x As Integer
Private Sub Panel1_Click(sender As Object, e As EventArgs) Handles Panel1.Click
Dim retString As String = InputBox("Enter Some Info", "Info...", "", -1, -1)
If retString.Trim <> "" Then
Dim p As Panel = DirectCast(sender, Panel)
Dim newPanel As New cardPanel
newPanel.Left = 6
newPanel.Top = If(p.Parent.Controls.OfType(Of cardPanel).Count > 0, p.Parent.Controls.OfType(Of cardPanel).Max(Function(cp) cp.Bottom) + 6, 19)
newPanel.Width = p.Width
newPanel.Height = 36
newPanel.BackColor = Color.White
newPanel.percentage = 0
newPanel.Text = retString
newPanel.Name = "Card" & x.ToString
FlowLayoutCard.Controls.Add(newPanel)
x += 1
AddHandler newPanel.MouseDown, AddressOf childs_MouseDown
Me.FlowLayoutCard.AllowDrop = True
End If
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
Dim p As Panel = DirectCast(sender, Panel)
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
e.Graphics.DrawString("Add card", p.Font, Brushes.Black, New Rectangle(Point.Empty, p.Size), sf)
End Sub
End Class
I need to add a contextmenustrip where I could delete the panels I created:
Something like this :
when I left click the added panel, a contextmenustrip appears "delete" and then when I click the delete, the panel is deleted.
Continue reading...