Click here to Skip to main content
15,040,090 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
please refer the link problem — ImgBB[^] for screenshot of the problem. I am using visual studio 2019 community edition. Also has Fontawesome.Sharp library installed in my project. Please help, I am new to windows forms environment. Any help would be highly appreciated. If you find it difficult to understand problem please ask for more details.

Thank you!!
Prasanna - .Net Developer and Entrepreneur

Please refer this link for detailed image I have used both problem-Screen2 — ImgBB[^]. I have used both tablelayoutpanel and datagridview contro. Both shows same problem.

What I have tried:

I have tried using TableLayoutPanel and DataGridView control to see if problem persists. But it did persists with DataGridView as well. I tried adding both tablelayoutpanel and DataGridView programmatically but still no luck. You can see the dark lines in the TableLayoutPanel as shown in screenshot in the link --> problem — ImgBB[^].

This is the code I tried

using System;
using System.Drawing;
using System.Windows.Forms;
using FontAwesome.Sharp;
namespace ModernUIApp.Forms
    public partial class MainForm : Form
        private IconButton currentBtn;
        private Panel leftBorderBtn;
        private Color currentColor;
        private Form currentChildForm;
        public MainForm()
            leftBorderBtn = new Panel();
            leftBorderBtn.Size = new Size(7, 40);
            this.Text = string.Empty;
            this.ControlBox = false;
            this.DoubleBuffered = true;
            this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;

        private void OpenChildForm(Form childForm)
            if (currentChildForm != null)
            currentChildForm = childForm;
            childForm.TopLevel = false;
            childForm.FormBorderStyle = FormBorderStyle.None;
            childForm.Dock = DockStyle.Fill;
            // childForm.Font.Size = 10
            pnlDesktop.Tag = childForm;


        private void button1_Click(object sender, EventArgs e)
            //ActivateButton(sender, RGBColors.color2);
            OpenChildForm(new ConferencesForm());
Updated 2-Sep-20 17:24pm
Richard MacCutchan 2-Sep-20 9:22am
You need to show the code that creates the form as it is impossible for anyone here to guess what you have written.
prasannanirmale 2-Sep-20 9:41am
I have updated the question with code. Thanks for the quick reply. Really appreciate.
Richard MacCutchan 2-Sep-20 9:59am
Sorry, I cannot see the connection between that code and your picture, or understand quite which part contains the problem.
prasannanirmale 2-Sep-20 10:55am
I have two forms MainForm and ConfernceForm. Mainform is main screen which has leftpanel, toppanel and middlepanel. middle panel named "pnlDesktop" is used to display child form "conferenceform" in this case. In Image you can see TableLayoutPanel to the right side of the middle panel. I have mentioned "problem" word in red color there. If you look pass button 3, button 4 etc. you don't see cell border. It has disappeared for unknown reason to me. I have used drag and drop controls to design most of the form.What you see in the picture is all static for now. And in the childform I have two panels "Contacts" and "Conferences". In contact panel I have TableLayoutPanel which display problem after loading in the MainForm. I hope this helps.

Thank you!
prasannanirmale 2-Sep-20 13:24pm
Thanks @Dave Kreskowiak, I am using form to load childform, thats true. Can we create whole screen as a user control as per my requirement? I have tried using datagridview in the next panel just to test drawing capabilities of the control. Its showing same problem. You can check this link for another screenshot attached.I have added this link to my question description as well.Any more help would be highly appreciated. Thank you!
Dave Kreskowiak 5-Sep-20 11:23am
Yes, you can create an entire "panel" of controls in a UserControl.

If all you're doing is laying out a bunch of buttons in a grid, using a DataGridView is a bad idea as it's a heavy control that comes with way more capability than you need to do that.

A TableLayoutPanel is a much better choice, plus it won't draw grid lines by default.

A TableLayoutPanel has seven options for CellBorderStyle: use one of the six options that draw the borders, if you want it to look like a grid.

As Dave said, do not use a Form where you can use a UserControl.

In your code pnlDesktop.Controls.Add(childForm)

0 your code does not define pnlDeskTop

1 childForm is just a generic, blank, Form: it will have no content other than the standard Form adornments and TitleBar controls: why would a blank Form be of any use at run-time ?,

You need to do some experimentation with Controls like DataGridView and TableLayoutPane, get oriented. Study UserControl creation, and how you enable interaction with its run-time Container (Parent Control).

If the user is creating some new instances of a control/component at run-time, what is the content ?

And, refine and edit your question here.
Maciej Los 3-Sep-20 3:11am
A TableLayoutPanel will not paint lines between controls, while a DataGridView will. So there's something in that "child control" you're doing but not showing in your question.

A TableLayoutPanel, like the name implies, adds additional layout capabilities to a form for controls. It's not really a "visible" control, but an extension to the controls it contains.

Also, your "child form", really shouldn't be a Form at all, but a UserControl. Forms come with more baggage that you wouldn't want to deal with when trying to use it as a control, like you appear to be doing.
BillWoodruff 2-Sep-20 23:07pm
A TableLayoutPanel has seven options for CellBorderStyle: six options will draw borders :)
Dave Kreskowiak 3-Sep-20 14:44pm
Yeah, but borders are off by default.
Maciej Los 3-Sep-20 3:11am
BillWoodruff 4-Sep-20 1:36am
My vote changed to #1: further reading of this solution, and DK's comment, have made me believe this is actually a misleading "solution," which DK, for whatever reasons, is not likely to update based on the actual behavior of the TableLayoutPanel in WinForms.

1 a new TLP dropped on a Form has by default 2 Rows and 2 Columns: the design-time view shows outlines on the 4 Cells. You can immediately drag-drop Controls into those Cells.

1a to show Cell borders ... as discussed ... you do need to set the CellBorderStyle at design-time, or, run-time.

2 if you show a TLP with no content (no Controls in Cells): you see just a blank grey rectangle on the screen at run-time ... unless you have set CellBorderStyle for the TLP ... which can done at design-time, or run-time.

3 While the TLP is missing design-time setting of the TLP's BorderStyle property (ask Microsoft !), it can be set in code like this:

tableLayoutPanel1.BorderStyle = BorderStyle.Fixed3D;

4 you can also set the Padding property for a TLP at design-time.

The typical uses and design/run time behaviors of a TLP and a DataGridView are so different I think they are not comparable. a TLP does not support data-binding !

Dave Kreskowiak 4-Sep-20 10:24am
Yeah, you can turn the borders on, but he didn't show that being done in the code. Everything seems to be using default behavior, so what should I change?

What he posted really doesn't show any sign of being able to put up the lines that he's talking about. I don't know where they are coming from. My "solution" was merely a suggestion to use the TLP over the DGV.

But, wow. Cheerios, meet piss.
BillWoodruff 5-Sep-20 1:42am
A very disappointing response, which is as inaccurate, in its own way, as a distortion of both the original question, and my explanation to you of why I down-voted your "solution," as your technically inaccurate "solution."

You are too intelligent to respond like this, confusing my attempt at technical accuracy and usefulness to the OP with an ad hominem attack.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900