Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In the control or layout container : </p> <ol> <li>define a <code>Dictionary&lt;Control,int&gt;</code> which will hold a current height variable for each Control of interest.</li> </ol> <p><em>In the initial Layout :</em></p> <ol start="2"> <li><p>recurse through Controls of interest (if nested), or </p></li> <li><p>iterate through Controls of interest (if not nested) </p></li> </ol> <p>... use "standard" iteration or recursion, Linq recursion, or Linq "iteration" ... :</p> <p>... as you recurse, or iterate, make an entry in the Dictionary for each Control with its current height ...</p> <p>... attach a 'SizeChanged handler to each Control of interest that invokes the same method in your Layout Engine Class (possibly a static method ?) : for the sake of clarity : let's refer to that as the "Event Dispatch Code."</p> <p><em>In your Event Dispatch Code for all Controls of interest,</em> now triggered by a SizeChanged event on any of your "monitored" Controls : </p> <ol> <li><p>do a dictionary look-up using the Control as a key : get the Height property value and compare with the Control's current Height value : </p></li> <li><p>assuming the Height property has changed :</p></li> </ol> <p>a. call your Layout Engine to "do its thing."</p> <p>b. update Dictinary value for Height for that Control.</p> <p>Note : since the SizeChanged event is going to be called with 'sender as an 'object : you will need to cast it to type Control before accessing its 'Height property.</p> <p>Here's a "rough sketch" of what your code might look like :</p> <pre><code>// note : untested code : use caution ... test rigorously ... // stub for the Dictionary of monitored Controls private Dictionary&lt;Control, int&gt; LayoutManager_MonitoredControls = new Dictionary&lt;Control, int&gt;(); // the SizeChanged Event Handler you "install" for all Controls you wish to monitor private void LayoutManager_SizeChanged(object sender, EventArgs e) { Control theControl = sender as Control; int cHeight = theControl.Height; if (LayoutManager_MonitoredControls[theControl] != theControl.Height); { // update the Dictionary LayoutManager_MonitoredControls[theControl] = cHeight; // call your code to update the Layout here ... } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload