DatagridView moving strange (or how to block your application)

Answered
0
0

Attrached a sample project (with basically 20 lines of code) and a short 15 seconds video with program running and problem happening:

– create a form with one exit button and a datagridView, and open with  ShowDialog. No auto-size, nothing additional. If you click inside the table and after that click outside the table (near the button), the datagridview is displayed on all windows, the button is probably hidden, so no way to get out.

I dont’t want a way to get out (it’s pretty trivial to do that), but what happens to datagrid covering everything?

private void button1_Click(object sender, EventArgs e)
{
Form f = new Form();
f.Size = new Size(600, 400);
f.StartPosition = FormStartPosition.CenterScreen;
f.FormBorderStyle = FormBorderStyle.FixedToolWindow;
f.Text = “test”;
f.ControlBox = false;

Button b = new Button();
b.Text = “Exit”;
b.Width = 100; b.Height = 25;
b.Click += delegate { f.Close(); };
b.Left = f.Width / 2 – b.Width / 2;
b.Top = 5;// f.Height – b.Height – 5;
f.Controls.Add(b);

Wisej.Web.DataGridView dg = new Wisej.Web.DataGridView();
dg.Width = f.Width – 10;
dg.Height = f.Height – b.Height – 10;
dg.Left = 5; dg.Top = b.Height + 10;
f.Controls.Add(dg);
f.ShowDialog();
}

  • You must to post comments
Best Answer
0
0

Hi Adrian,

your code is wrong. Change line 36 to this and it should work as intended:

dg.Height = f.ClientSize.Height - b.Height - 10;

Best regards
Frank

  • Adrian Zagar
    Working great. Thank you!
  • You must to post comments
0
0

Hi Adrian,

please attach a complete runnable test case for us to take a look at.

Best regards
Frank

  • Adrian Zagar
    Hi Frank, In my first post there is a complete runnable test. I also attached a video (of the same project) to instruct on how to replicate the problem.
  • Frank (ITG)
    Hi Adrian, in this free support forum we cannot work only on snippets, videos or screenshots. We need complete runnable test code to investigate. Best regards, Frank
  • Adrian Zagar
    Hi Frank, You got me wrong. In my first post there is a complete runnable test, meaning that in file testWisej35.zip there is the full project. The video is just a helper in case someone doesn’t understand how to reproduce the described behavior using the project provided.
  • Frank (ITG)
    Hi Adrian, you’re right, sorry I missed it. We’ll check and get back to you. Regards Frank
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.