Inconsistence between design and runtime in inherited control

0
0

Hi,

I have problem with design  inherited control. Please take a look at the attachment:

flowLayoutPanel1 is outside of designer of InheritedDataForm and Anchor is set to Left, Bottom, Right. But in runtime it comeback.

Thanks for your help,

Page

Attachment
  • You must to post comments
0
0

The issue is that the designer in Wisej fixes the error in the code but if you don’t save it you will get the error at runtime.

The code from VWG is wrong, and it may have worked because of a bug in VWG layout.

Anchoring anchors a control to the parent’s sides. Looking at the code you have coming from VWG, you can see that:

  • In BaseDataForm the continer (BaseDataForm) is 1051×526 (screenshot attached)
  • The dataGridView is 1042×353 anchored top,left,right,bottom.
  • In BaseDataForm the flowLayoutPanel1 is anchored left,right,bottom and it’s 895×28 at 4,371.
  • Both datagrid and flowLayoutPanel1 are relative to their parent splitContainer.Panel2 which is 1051×410.

This shows identical in the designer and at runtime. Anchoring the datagrid t,l,r,b means that the proportional distance on the 4 sides is maintained: when the container is resized, the distance of the datagrid’s 4 sides to the container is preserved.

Since the grid us 352 in height and the parent splitContainer.Panel2 is 410 in height, the bottom of the grid will always be 410-352 = 58 pixels from the bottom of the panel.

The wrong code is in InheritedDataForm:

  • InheritedDataForm in the code you attached is 1227×912 (line 183: this.Size = new System.Drawing.Size(1227, 912);)
  • The size of splitContainer.Panel2 is 1227×883
  • BUT the datagrid in InheritedDataForm has the wrong size (line 96: this.dataGridView.Size = new System.Drawing.Size(1073, 635);)
  • AND The flowLayoutPanel1 in InheritedDataForm has the original location (line 100: this.flowLayoutPanel1.Location = new System.Drawing.Point(196, 700);)

Looks like the designer code in InheritedDataForm was changed by hand or VWG generated the wrong dimensions.

Which means that in InheritedDataForm the size of the grid and the bottom of the grid are much smaller than the parent and the bottom grid will be 883-635=248 pixels from the bottom of the container.

The layout depends on the state of the layout engine and the corresponding calls to SuspendLayout() and ResumeLayout() and the designer is applying them in the design order to fix the layout, but you need to save it or the wrong code will run at runtime.

The only issue I see is that the designer didn’t mark the file as modified when it should. See screenshot 2, the designer changed the grid to be 1249 x 1021 to make it work but if it’s not saved the original proportions will be used at runtime.

 

 

Attachment
  • You must to post comments
0
0

Hi Page,

How did you create InheritedDataForm? It looks like the sizes (and locations) are all off.

I just tried by:

  1. Right-Clicking Project
  2. Add -> New Item -> Wisej 2
  3. Select Inherited User control
  4. Select BaseDataForm

This gave me a control that was identical to BaseDataForm (superclass), with flowLayoutPanel1 in the appropriate place.

The reason InheritedDataForm probably looks okay in your browser is because it’s larger than the Designer and the anchoring keeps it at the bottom of your screen.

I think if you try creating a new inherited control with this method it will solve your issue!

Let me know!

Best,

Levie

 

  • Page Page
    Hi, the example is what i got when migrating code from VWG (with minimized code). I understand what you did, but it does not help in my case. I need to customize inherited control ( add more other controls and change location, size some controls…). As I understand, Anchor of flowLayoutPanel1 is related to InheritedDataForm, not the browser, when InheritedDataForm changes its size, flowLayoutPanel1 should move outside like in designer. I have a lot of inherited usercontrol in VWG and now I have to redesign and it is very hard because in designer it is different from runtime. Sometime i close the inherited usercontrol designer and open it again, it is not the same as before closing. May be the splitter causes the problem, but I’m not sure. Thanks for your help, Page
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.