sorry, but I didn't find a better way to describe the problem I have with my small application.
well, it's like this (I'm using WinForms, Visual Studio 10):
the main window has a menuestrip and a panel, called DevicePanel (using Dock.Fill)
the DevicePanel holds other panels (ItemPanels) of equal size, where size depends on the number of ItemPanels.
the maximum number of ItemPanels is 16 and they are arranged in rows of maximum 4 per row.
if there exist more then 4 ItemPanels, I want to draw a horizontal line between each row.
in the ItemPanel PaintEvent I check the panels index and if it's the last panel,
I draw the line(s), using the DevicePanels Graphics context. However this does not work.
I also tried drawing the line(s) in the main windows ShownEvent, but this too doesn't work.
so my question is how and where do I draw the lines? Be free to ask for addiational information.
for your answers many thanks in advance

Franz HeynPosted May 21, 2024, 5:25 PM
@Jayraj Chhaya
your provided code does not work in many ways. you neglect the Device'Panels child panels. the lines might by drawn but the childpanels will override the lines. Another issue is the fact that your DevicePanel does not do DockStyle.Fill, its location is 0/0 instead of 0/menustrip.height, thus from the first row panels part is cut.
instead of class DevicePanel I've added a UserControl but that does not work too.
Jayraj ChhayaPosted May 21, 2024, 6:05 AM
To draw horizontal lines between rows of panels in a WinForms application, you need to handle the drawing logic correctly. One approach is to override the
OnPaintmethod of theDevicePanelcontrol and draw the lines thereBy overriding the
OnPaintmethod of theDevicePanelcontrol, you can draw the horizontal lines between rows based on the number of panels dynamically. This ensures that the lines are drawn correctly when the control is painted.