C# App - Issues with docking, controls not logical

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gun Slinger
    New Member
    • Feb 2008
    • 27

    C# App - Issues with docking, controls not logical

    Hi guys,

    Just a quick question which i am fairly stumped with. I have had a look around, but it seems to be so simple there hasn't been many problems with it from other people.

    My issue is that i have a toolstrip and a datagridview and the datagridview isnt finding the toolstrip above it, and when it is doing a fill dock it is cutting a part of itself off from the user.

    I have created these objects using code (has to be through code) and they are inside of a splitcontainer.

    Code:
    ToolStrip strip = new ToolStrip();
    
    DataGridView grid = new DataGridView();
    DataGridViewButtonColumn columnn = new DataGridViewButtonColumn();
    grid.Dock = DockStyle.Fill;
    grid.Columns.Add(columnn);
    
    splitContainer1.Panel2.Controls.Add(strip);
    splitContainer1.Panel2.Controls.Add(grid);
    I have tried adding a dock to the toolstrip and invalidating the panel, but it dosent seem to work.

    Any help would be really appreciated.

    Cheers
  • Looser
    New Member
    • Dec 2008
    • 3

    #2
    simply change the order of lines, where you are adding controls to your parent control (panel2)
    So change order of 8. and 9. line to:

    splitContainer1 .Panel2.Control s.Add(grid);
    splitContainer1 .Panel2.Control s.Add(strip);

    Comment

    • Gun Slinger
      New Member
      • Feb 2008
      • 27

      #3
      wow.... that simple. I was sure i tried that before.

      Logically i was sure its the otherway around though. Cause the datagridview would see that there was a toolstrip and make sure that it didnt overlap.

      Thanks dude. Answered!

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I believe that when the control is added, it "adjusts" any other controls that are already there, not adjust itself after examining what is already there

        Comment

        Working...