By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

C# App - Issues with docking, controls not logical

P: 27
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.

Expand|Select|Wrap|Line Numbers
  1. ToolStrip strip = new ToolStrip();
  2.  
  3. DataGridView grid = new DataGridView();
  4. DataGridViewButtonColumn columnn = new DataGridViewButtonColumn();
  5. grid.Dock = DockStyle.Fill;
  6. grid.Columns.Add(columnn);
  7.  
  8. splitContainer1.Panel2.Controls.Add(strip);
  9. 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
Dec 8 '08 #1
Share this Question
Share on Google+
3 Replies


P: 3
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.Controls.Add(grid);
splitContainer1.Panel2.Controls.Add(strip);
Dec 8 '08 #2

P: 27
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!
Dec 8 '08 #3

Plater
Expert 5K+
P: 7,872
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
Dec 8 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.