|
Hi every body,
I have to forms, each form has a tree that is exactly the same with the other, the best way is to use one tree control for both form, but I realize that when you add a control to another parent, the former parent will remove it from it's Controls' list.
You have any idea to solve my problem?
Thanks a lot!
Regards.
|
|
|
|
|
A Control can only be visible once, it has at most one Parent, and resides in at most one Controls collection. So it is fine to move a Control around in some cases:
- from one tab page to the next when these pages belong to the same TabControl (hence at most one of them is showing),
- from one modal dialog to the next (at most one of them showing again)
but you can't reuse a Control in general. You would have to have two Controls, and use code to keep them synchronized.
modified on Saturday, April 11, 2009 1:25 PM
|
|
|
|
|
Pity
It's a MDI application, user can even move the MDI forms around and align them parallely to work together. Now I have many troubles synchronize them. Anyway, thanks for you answers, I can use them in some other cases.
|
|
|
|
|
A control can have only one parent. There's nothing stopping you form removing the control from one parent's Controls collection and adding it to another though.
|
|
|
|
|
I have 50 radio buttons in a form. can i use a loop to check which radio button is checked ?
|
|
|
|
|
Yup. You'd typical loop through the Control -collection of the form, checking if the Control is a radioButton , and if it is, downcast it to a RadioButton and read the value.
--edit--
Forgot to close one of the <code> tags
I are troll
|
|
|
|
|
hi i am using like this..
opt_no=1;score=0;
foreach (Control rd in this.Controls)
{
string rdo= "radioButton"+opt_no";
if (rd.Name == rdo && rd is RadioButton)
{
// my code is here
rd.Checked=true; // the line gives an error
}
opt_no= opt_no+1;
}
it takes only that control which is designed into form. but i designed all radio buttons into flowLayoutPanel.
i have 100 question and each Que. has four option(means four Radio button which is created in a panel).i am checking score.
i am taking question no and ans from a table.
|
|
|
|
|
Ravindra Bisen wrote: each Que. has four option(means four Radio button which is created in a panel)
Sounds like a user-control to me
I are troll
|
|
|
|
|
Ravindra Bisen wrote: 50 radio buttons in a form
Why?
If you've got this many options, maybe a dropdown combo or a list would be a better idea? With either if these finding the selected item is easy.
Alternatively if you absolutly must have all the radio buttons, on the CheckedChange event catch the pressed button as it will be the object sender.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
The alternative is to have a class member RadioButton LastChecked and to give all RadioButtons the same CheckedChanged handler, which simply updates LastChecked=(RadioButton)sender; for the last one whose Checked property became true.
|
|
|
|
|
It may be cleaner to use LastChecked = sender as RadioButton instead, then just check if LastChecked is null. That way, you don't have to go through exception handlers if you get an InvalidCastException
|
|
|
|
|
as williamnw pointed out, try to chnage you design. 50 radio buttons is way too much. It can be replaced with drop down or list control.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
I need help with modifying the parts of the cosmos code such as process management,
process synchronisation, scheduling or deadlocks.
can anyone show me an example?
thanks.
|
|
|
|
|
Please, try and ask a question that someone can answer. Read the top of the page post - what does it say - and then consider showing what you've tried. There will be one of two answers depending on your question:
Q. Why not work? rgnt!
A. Foff and die.
Q. I tried this [code example] and the following happened [output]. I expected [this]. Can anyone help?
A. Sure, change [bing] to [bang] and yall cookin ona BBQ.
Enjoy!
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I wouldn't recommend it. Operating system development is a very complex subject; you need to understand boolean logic, assembly code and other complex topics just to get off the ground. To actually get something 'simple', like a mouse cursor, you'll need to be very familiar with sprite rendering techniques, how double-buffering is implemented, and how to make a mouse driver. With COSMOS, it's more complicated, as you'll need to understand how the IL2CPU compiler works. This is another subject which is difficult to understand
An example is difficult, if not impossible to give when it comes to an operating system. Unless you write the code yourself, and know the system intimately, you won't know how it integrates. This will make your debugging infinitely harder
|
|
|
|
|
But doesnt cosmos come with a source code? any existing source code that you can modify or u have to write the whole code if u need to???
thanks,
|
|
|
|
|
It comes with lots of source code. Modifying it isn't just a question of copying/pasting code and pressing F5 to see if it works.
Why not download the code and take a look at it?
--edit--
I forgot the HTML closing-tags again. Just corrected it
I are troll
|
|
|
|
|
It does. But it's going to be a lot harder to debug if you don't know how it works. This is not normal software development - you need to have good knowledge on how COSMOS works in terms of code, and how it gets compiled down to ASM. Generally, you need to have looked at the source code from the beginning to have that kind of knowledge
No, you don't have to write the whole code - that would take years! You could try to get an in-depth understanding of the code, then either do a fork, or contribute to the main project. But you shouldn't make an OS from somebody else's code. If you did that, it wouldn't really be 'your' code, and you would lack some of the basic skills necessary to make repairs (understanding the base infrastructure). Of course, if the COSMOS artists read the message board, I'd welcome any further comments
|
|
|
|
|
Hi I have load an image in the background but i would like to show HAND cursor in some area (e.g button on a background image). I am able to do it for whole form or background image but not for a part of it.
|
|
|
|
|
There is a Cursor property for almost every Windows control.
Lets a assume we have a Button control say button1 and we want to change its cursor then we will use the following code:
button1.Cursor = Cursors.Hand;
Hope it will help.
Don't believe in love...
|
|
|
|
|
There is a cursor property for almost every Windows control.
Lets assume you have a Button say button1 and you want to change its cursor to Hand now you will have to use following code:
button1.Cursor = Cursors.Hand;
Hope it will help.
Don't believe in love...
|
|
|
|
|
You asked this a little while ago.
DON'T do this!
VERY, VERY rude.
You are not giving sufficient information about your problem for anybody to give you an accurate answer.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
thanks for reply my dear friend but little while ago i was asking about trapping mouse event, which i am able to handle now. but what i want now is on mouse over i want to show HAND cursor. As explained i have background image and on that i am having one more small image of a card (e.g Heart one), and i want whenever user take mouse over this card the cursor should get changed to HAND. I know that every control is having a property of cursor but this is an image (HeartOne.jpg) which is drawn over another image (BG.jpg)
|
|
|
|
|
If you are drawing the card image, then you know where it is on your form. You know its location and you know its size, therefore you can construct a rectangle from that information.
What you need to do is to keep a record of the rectangles for all the cards on your form. I'll leave you to research on how to do that.
Then when the mouse cursor moves you will have to go through all those rectangles to see if they hold the mouse position within their boundaries.
Look at the MSDN documentation for Rectangle to find a suitable method for that.
Your form is a control, therefore it has a Cursor property, you already know about that, so need no help on it.
Look away now! RANT coming up!
In the first post in this thread you stated that you had asked before but were not getting answers. In your previous post you were asking about detecting when the mouse was over an image. Rewording the question does not make an entirely different post! Stick to the rules. Remember that there are time differences, you are getting responses from all round the world. While you are working, others are asleep. If your problem is so damned urgent then get your credit card out and visit rent-a-coder, otherwise learn patience. I, and others, had responded to your first post, this thread should have been a continuation of that first post. Learn the rules of the forums, and keep to them, otherwise people will just ignore you.
Rant over.
For what it's worth I think that you are going about this in the wrong way. Ask yourself these questions, "What happens when the user clicks on one of the 'cards'? How do you as the programmer know what 'card' it is? Is it a Heart or Spade, is it a ten or an Ace?"
However you should at least complete the part you are doing, before changing your design, because you will learn many useful techniques. Also bear in mind that what you are doing is essentially a 'drawing' program. it's just that you are drawing cards whilst they draw circles, squares etc. So before you ask any more questions about this, Google for 'sketch program c#' or 'drawing program c#' and anything else like that that springs to mind, take a look at that code, it should give you many ideas on how to do your application.
Good luck!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Thanks for your reply and suggestions. I ll certainly see to it. Now I am able to do as per the position of images by using MouseMove function.
|
|
|
|