|
Hi,
A button does not hold any data (unless you hide something in its Tag).
The normal approach is to have your data structured somehow and stored in class members.
Then these data may get operated upon by Controls, such as a Button causing an OpenFileDialog to
appear, and a file being read; and an OnPaint method may read the same data to display something
on the Form or one of its Controls (such as a Panel).
|
|
|
|
|
I have a user control (which for the purposes of this post is just a container), and several nested user controls. I want to lay out the child controls inside the container in a similar way to the following picture:
http://mi6.nu/docking.jpg
I've tried different combinations of Anchor and Dock properties as well as using a Flow Layout Panel, but I can't get it to work.
The two things I know are:
1) The location of each child control on the Y-axis
2) The height of the control
I need some way to assign these controls a combination of properties and have them stack up as shown in the picture. Full width child controls should float to the left, and if there's more than one child control at a Y location (eg: 3 and 4), the available space should be split.
I managed to get it sort of working, but items were overlapping.
|
|
|
|
|
Have you looked at adding a SplitContainer into the mix?
I'm thinking that if you dock one panel on the left side of the form (or control), dock a second panel in the upper-right, a third panel in the bottom right, and place a SplitContainer into an area you leave open between the two panels docked on the right, then you can place your #3 and #4 controls in the split container panels, and not worry about any overlap. You could set the IsSplitterFixed property to True to prevent the user from resizing the split, and make the splitterwidth small enough that it is unseen.
Anyways, that is one idea, I won't be surprised if there are better ideas...
|
|
|
|
|
yep, do it hierarchically, i.e. split your form in two parts (that would be 1 versus 2+3+4+5) using
either a SplitContainer or two Panels; give those the right anchoring.
Then iterate for the next split (5 versus 2+3+4). Etc.
|
|
|
|
|
Thanks for the quick response. I didn't explain myself very well. The number of child controls isn't a fixed value. In the example there are two items with the same Y value, but there may be just one, or four or five.
|
|
|
|
|
I don't know which Control would help you split a distance in N equal parts, N being possibly larger than 2 and not a power of 2.
The way I used to do all these things, before I was even aware of anchoring and SplitContainers, is
by calculating Top, Left, Height and Width myself, by code, in the OnResize handler. Takes some code,
but does exactly what you want with no additional Controls to achieve your layout.
|
|
|
|
|
I still do it the way that Luc mentioned in his post above. It's alot more code but it leaves you in control!
Dave
|
|
|
|
|
Looks like mountains of code it is then.
I always try to avoid excessive code, especially in OnPaint methods, but there are times when it's unavoidable.
|
|
|
|
|
...
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
|
|
|
|
|
I agree. How do we stop the dots...
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Press the stop button.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Well, the best way to do this in the presented situation would be pressing the power button. It'll surely stop what you need.
|
|
|
|
|
Sincerely.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Just power down the computer and walk away
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
> ...
&who: ...
&message: "incorrect usage of auxiliary keyword"
&syntax: ...
&trace: #<syntax ...>
|
|
|
|
|
Hi All,
I have an application which displays the fonts in "Segoe UI".
But if I run the same application on another OS on which the font is not available.
It is displaying the font in "Microsoft Sans Serif".
Is there any way to change the default font to "Tahoma" on those machines ?
Thanks in Advance.
Appu..
"Never explain yourself to anyone.
Because the person who likes you does n't need it.
And the person who dislikes you won't believe it."
|
|
|
|
|
You can explicitly set the font on each form so that it will use that font on all operating systems, if available. However, leaving the font settings as is will cause the application to display using the default font for that operating system, which is generally what you want.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
Hi,
i am developing an application in C# 2.0 which uses BHO and multi threading. i am getting following error:
"Context 0x15da88' is disconnected. Releasing the interfaces from the current context (context 0x15d860).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that live inside them."
can any body tell me whats the reson for this error and how can i resolve it? VS dosnt tell me the original location of error, so i am helpless and dont know from where to start debugging. any kind of help is appriciated. Thanks,
Regard,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Hi,
I ve written a code something like below in Click event of Button btnWindows:
...
...
btnWindows.Enabled = false;
MessageBox.Show("Good Morning!");
for (int i = 1; i <= 500000; i++)
{
for(int j =1; j <= 500;j++)
{
}
}
btnWindows.Enabled = true;
...
...
in above code, instead of inner For loop i ve some calculation that takes about 6 to 7 seconds to finish.
The problem is,
when button gets disabled and message box comes
after that when i click on disabled button ( Or, access it through its Hot Key ) the click event gets fired again and i m wished "Good Morning!".
Waiting for some helpful answers !!
|
|
|
|
|
You have everything in one segment of code. If the code is in the click event of the button then "Good Morning" should always show. Keep in mind that you are enabling the same button after the for-loops that you disables before the for-loop. The button will only be disabled for the [milli]seconds until the for-loops are complete.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Thanx Thomas,
But then how can i avoid the further click events of the button.
In this case the for-loop takes about 6 to 7 seconds to finish
and if in between the user click the button the process starts again
after finishing once.
(if i put one more message box after the for-loop then the click doesnt fire again,
but i dont want to go that way)
Regards,
SIFAR.
|
|
|
|
|
Is there a delay in your enabled property changing?
Immediatley after you disable it but before the MessageBox, try btnWindows.Refresh();
Dave
|
|
|
|
|
What I would suggest is having a boolean variable for the class.
Pseudocode:
bool tmpCanContinue=true;
public void Button_Click(Object sender, EventArgs e)
{
if(tmpCanContinue)
{
tmpCanContinue=false;
...work with the for-loops
tmpCanContinue=true;
}
}
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Part of the problem may be that you won't get to the for loops until you clear the MessageBox.
|
|
|
|