G
GodspeedSupreme
Guest
Can Someone please explain this to me?
newPanel.Top = If(p.Parent.Controls.OfType(Of cardPanel).Count > 0, p.Parent.Controls.OfType(Of cardPanel).Max(Function(cp) cp.Bottom) + 6, 19)
for example, this panel1_click is inside an Panel or Flowlayoutpanel. How do I set the Flowlayoutpanel or panel as its parent?
This is the full code:
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
p.Parent.Controls.Add(newPanel)
panels.Add(newPanel)
p.Top = newPanel.Bottom + 6
x += 1
AddHandler newPanel.MouseDown, AddressOf childs_MouseDown
Me.FlowLayoutCard.AllowDrop = True
End If
End Sub
bytheway.. cardpanel is a component:
Codes:
Public Class cardPanel
Inherits Panel
Private _percentage As Integer
Public Property percentage() As Integer
Get
Return _percentage
End Get
Set(ByVal value As Integer)
_percentage = value
End Set
End Property
Private _text As String
Public Shadows Property Text() As String
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(212, 157, 93)), New Rectangle(0, 0, CInt((MyBase.Width / 100) * percentage), 6))
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
e.Graphics.DrawString(Text, MyBase.Font, Brushes.Black, New Rectangle(Point.Empty, MyBase.Size), sf)
MyBase.OnPaint(e)
End Sub
End Class
Continue reading...
newPanel.Top = If(p.Parent.Controls.OfType(Of cardPanel).Count > 0, p.Parent.Controls.OfType(Of cardPanel).Max(Function(cp) cp.Bottom) + 6, 19)
for example, this panel1_click is inside an Panel or Flowlayoutpanel. How do I set the Flowlayoutpanel or panel as its parent?
This is the full code:
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
p.Parent.Controls.Add(newPanel)
panels.Add(newPanel)
p.Top = newPanel.Bottom + 6
x += 1
AddHandler newPanel.MouseDown, AddressOf childs_MouseDown
Me.FlowLayoutCard.AllowDrop = True
End If
End Sub
bytheway.. cardpanel is a component:
Codes:
Public Class cardPanel
Inherits Panel
Private _percentage As Integer
Public Property percentage() As Integer
Get
Return _percentage
End Get
Set(ByVal value As Integer)
_percentage = value
End Set
End Property
Private _text As String
Public Shadows Property Text() As String
Get
Return _text
End Get
Set(ByVal value As String)
_text = value
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(212, 157, 93)), New Rectangle(0, 0, CInt((MyBase.Width / 100) * percentage), 6))
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
sf.LineAlignment = StringAlignment.Center
e.Graphics.DrawString(Text, MyBase.Font, Brushes.Black, New Rectangle(Point.Empty, MyBase.Size), sf)
MyBase.OnPaint(e)
End Sub
End Class
Continue reading...