I am trying to display three things in a row on a page.
First, a string of text saying "Name", second a Textbox, third a button that says "Submit".
What is the best way to display this row of objects by having the width of the screen that shows the string only be the width of the string; the button aligned to the right, taking up only as much width as the button needs to show the text on it; and the TextBox in between those 2 things filling up the width between them? So, if the screen is resized the "Name" string and search button stay the same widths on either edge of the screen, but the textbox will shrink or expand but still fill up the entire width between the other two objects.
I tried using percentages for the object widths, but I'm not getting the results I want. Any ideas?
Loading
Sam HobbsPosted Apr 7, 2010, 6:17 PM
MattPosted Apr 7, 2010, 2:38 PM
First of all, should this code go on my .aspx page or the .aspx.cs page? How do I access ClientSize? And where does the OnSize event handler come from?
Sorry if these seem like trivial questions; I'm new this. I do have to figure this out very soon - any pointers in the right direction, or example code/pseudocode would be of great help. I've attached my source code; could you point out where I would insert the code and what it would look like; I'm having trouble understanding where the size checking takes place.
MattPosted Apr 5, 2010, 8:37 PM
That is indeed what I am trying to do! I will give it a shot. Sorry my last message was so confusing; I was writing in haste because I was running late for something.
Matt
Sam HobbsPosted Apr 5, 2010, 2:21 AM
If that is correct, then what I would do is that in the form constructor, I would subract the left side of the button from the ClientSize width, giving the position of the button relative to the left side of the window. I would also save the difference of the button's left side minus the textbox's right side. The right side can be determined by adding the left side to the width. Then in the OnSize event handler, I would set the button's position based on the ClientSize minus the position determined previously and set the textbox width based on the new position of the button.
I hope that is not too complicated.