Note that there are some explanatory texts on larger screens.

plurals
  1. POPositioning controls in the middle of a CheckBox
    text
    copied!<p>THis is a followup to my previous question "<a href="https://stackoverflow.com/questions/37306/font-dependent-control-positioning">Font-dependent control positioning.</a>" It's an attempt to solve the <em>real</em> problem behind that question, perhaps in ways different than the one I was asking about.</p> <p><strong>Example of the problem statement:</strong> I want a checkbox that says "Adjust prices by <em>&lt;X&gt;</em> <em>&lt;Y&gt;</em> after loading," where <em>&lt;X&gt;</em> is a number---adjustable with a <code>NumericUpDown</code>---and <em>&lt;Y&gt;</em> is either "percent" or "dollars," with the choices being made by a <code>ComboBox</code>. This will be on a single line.</p> <p><strong>The complication:</strong> I want to be able to change my fonts for all these controls (basically setting them to <code>System.Drawing.Fonts.MessageBoxFont</code>, which is Tahoma 8 pt on Windows XP/etc. and Segoe UI 9 pt on Vista), without messing up my layout, which with my current <code>Position</code>-property--setting paradigm does not work.</p> <p>More generally, I'd like the controls to be dynamically laid out in a font-independent way, so that the <em>&lt;X&gt;</em> <code>NumericUpDown</code> fits snugly into the space between "by " and the <em>&lt;Y&gt;</em> <code>ComboBox</code>, and similarly the <em>&lt;X&gt;</em> <code>ComboBox</code> fits in with respect to the <em>&lt;X&gt;</em> <code>CheckBox</code> and the string " after loading" to its right.</p> <p><strong>The part everyone seems to miss:</strong> This is all nested within a <code>CheckBox</code>. So, ideally, clicking on the words "after loading" should check/uncheck the checkbox, and draw that little highlight rectangle around "Adjust prices by&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;after loading." So just slapping an extra <code>Label</code> on the end doesn't work, because then it doesn't toggle the <code>CheckBox</code>; similarly, trying to band-aid things by hooking up such a <code>Label</code>'s <code>Click</code> event won't produce the desired highlight-rectangle.</p> <p><strong>Solutions?</strong> At this point I'm thinking either:</p> <ol> <li><p>Rethink the problem, somehow, maybe with an ugly solution like two separate lines of text: "Adjust found prices after loading" (<code>CheckBox</code>), "Adjustment amount:" (<code>NumericUpDown</code> and <code>ComboBox</code>). This is really bad because my options box is absolutely full of options of this type (i.e. the type in the example), so it would at least double in vertical size.</p></li> <li><p>Some sort of custom control? <code>SplittableCheckBox</code>?</p></li> <li><p>Some kind of magic with a <code>TableLayout</code> control? (Pretty sure this fails at "the part everyone seems to miss.)</p></li> <li><p>Give up and either go back to MS Sans Serif, or use Tahoma uniformly, or package Segoe UI with my application, thus disrespecting the system default fonts.</p></li> <li><p>(New, via edit) Switch to WPF, if someone can convince me that it supports this scenario exactly.</p></li> </ol>
 

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