|
Hi all,
i want to call a sub form, but i really dont knwo how to achieve that.
I mean that when i start new project in C#.net, now with in the main form i want to drag few buttons and now when i click each buttons new form comes up with in that form....its like a parent and child form within same form with just a button click....
I hope i was not that confusing....
Pls help me out in this....
Thanks
|
|
|
|
|
Software_Specialist wrote: and now when i click each buttons new form comes up with in that form
Form newForm=new MyButtonActivatedForm();
newForm.ShowDialog();
[edit]Oh, you want the new stuff to be in the same form? Create a Panel in the form, put your controls in the panel and hide the panel. When the user clicks on a button, show the panel.[/edit]
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
yeh i want that on the same form...
but i am bit confused here,
1.) ok i dragged the panel
2.) now with in that panel i can add whatever functionality i want in the sub form..
3.) now i add button in the main form outside the panel...
4.) and i hv to call the panel with that button press....
is that right wt i said above or i am taking it wrong way. also can you tell me what exact code should i write to call panel...
thanks for reply...
|
|
|
|
|
Software_Specialist wrote: is that right
Sounds about right. If your panel is called "panel1", then panel1.Hide() hides the panel, and your button click would call panel1.Show()
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
The best way to do this is to design your sub forms as controls, put them all on the form, and change the visible property to change which subform you're seeing.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
What was trick to change inheritance to something else... design all like form than change what it inherit and it become control we can add to form actually?
|
|
|
|
|
Inheritance doesn't play into it. You just create controls, which have public and private members, and probably delegates, so that the form that consumes them can subscribe to events and show/hide controls as needed.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Christian Graus wrote: Inheritance doesn't play into it. You just create controls, which have public and private members, and probably delegates, so that the form that consumes them can subscribe to events and show/hide controls as needed.
OK I got it... this is part I found here:
Do a normal form, then when you happy, happy with it, change inheritance to usercontrol. And that does the trick.
Must try that out... so basically I design normal form, than just change all to control and and I can put it on form like it's normal thing not other form.
Is this OK method to do this thing?
|
|
|
|
|
Thanks for reply.
But what do you exactly mean by "design your subforms as control". is there any article discussing this issue or if you could elaborate it lil more then it would be great.
Thanks
|
|
|
|
|
I mean instead of designing a form, create a user control and design the form on that.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I am loking for a source code about de connected components. This analysis type is used in segmentation of texts and images. My interest is in the segmentation of images.
jlgr
|
|
|
|
|
I have a menu control on a master page that is attacted to a sitemap that is large. There are 236 items in the sitemap and it's about 52k file size. When I change content pages, there is a 2 second delay for the menu to refresh (reload). Does anyone have ideas how to make the faster? I realize that the content page is a "new" page so the control must reload. Maybe I shouldn't be using a master page?
in example, I have 2 aspx content pages based on 1 master page with a menu control on it. When I click from one content page to the other, the menu takes about 2 seconds to load.
I've tried putting the menu control on a custom control and caching it but that doesn't gain me anything since the other context page is a new page.
Thanks, Jessica
|
|
|
|
|
I want to redraw or repaint only a part of screen..... how can I do that if the part I want to repaint is not a rectangle.......
|
|
|
|
|
try
public void Control.Invalidate(Region region);
|
|
|
|
|
Is there a Whirlpool class in .NET?
|
|
|
|
|
A what???
I take it you're talking about the Whirlpool hashing algorithm?? No, there isn't. You have to implement it yourself. You can find a Java version here[^] and convert the code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
hi,
i have a problem concerning thread syncing with a manualresetevent. my code looks as below:
//this is a part of the callback of a receiving thread, qpt never gets null
//messageReceived is a manualresetevent
string qpt = myString.Substring(0, index);
Queue.Synchronized(this.Messages).Enqueue(qpt);
messageReceived.Set();
//and this is the code of my main thread, waiting for messages arriving in the queue
if (Queue.Synchronized(this.Messages).Count <= 0)
messageReceived.WaitOne(); //really waits (commented the .set)
Monitor.Enter(this.Messages);
string curLine = (string)(Queue.Synchronized(this.Messages).Dequeue());
messageReceived.Reset();
Monitor.Exit(this.Messages);
//...doing something with curline
when dequeuing, the element count is still 0. why? the queue isnt used anywhere else and it works with
while(true){
if (Queue.Synchronized(this.Messages).Count > 0)break;
}
instead of waitone (but takes 100%)
it seems that it takes a while until the queue recognises its new elements (does work with waitone if i place a debug point at waitone and always press play...). i also tried different combinations of monitor.enter, Queue.Synchronized with same results.
any ideas?
|
|
|
|
|
The Synchronized method returns a new synchronized Queue. Create it once and reuse it instead of creating it over and over again.
|
|
|
|
|
I dont agree.
The following code snippet gets three strings out of the queue
before it generates an exception:
Queue q=new Queue();
for (int i=0; i<3; i++) Queue.Synchronized(q).Enqueue("item"+i);
Monitor.Enter(q);
for (int i=0; i<4; i++) {
log("Count="+q.Count);
string s=(string)Queue.Synchronized(q).Dequeue();
if (s==null) log("<null>");
else log(s);
}
Monitor.Exit(q);
For me the synchronized queue works just fine (either with or without the monitor stuff).
Luc Pattyn
|
|
|
|
|
you are right. i tested it with only one synced queue and it has the same behaviour. i also tested an arraylist
lock (Messages) {
this.Messages.Add(qpt);
}
messageReceived.Set(); //one and only place where it gets signaled
--------------------------
while(true){
messageReceived.WaitOne();
//dirty fix
if (this.Messages.Count <= 0)
continue; //is called few times until count is really >0
string curLine = "";
lock (this.Messages) {
curLine = (string)(this.Messages[0]);
this.Messages.RemoveAt(0);
}
if(this.Messages.Count <= 0)
messageReceived.Reset();
/*curline action*/
}
instead of the queue with same results. the event is only signaled after something is added to the list, but if the waitone releases, often, not always, count is still 0.
am i stupid or what?!
|
|
|
|
|
I dont know what is going wrong in your code, it seems all right.
The only thing I can imagine is you could have more than one thread executing the
consumer sequence (waitOne + get Count): an Event.Set would signal ALL waiting threads
and only one of them would actually find something in the collection.
What IS executing the consumer sequence ? a timer event handler ?
And is it running on the UI thread ? How many threads are there ? etc.
If you want more help, I suggest you publish larger parts of your code.
My overall advice is to include (more) logging, so you can see what is going on.
Luc Pattyn
|
|
|
|
|
OK, you are right again. I finally found the solution. Always wondering where or what was releasing my waitone(), I realised that it must come from other instances of my class. So i thought why the heck can they? I always create a new ManualResetEvent, don't I?! The answer is yes, but it was static!
Shame on me and thanks for your answers,
vb
modified on Tuesday, December 30, 2008 5:50 PM
|
|
|
|
|
Hi!
I have a project say 'project1'. I have added some configuration sections to app.config file. The configuration sections contain initialization data for various objects. The objects read those configration information to initialize themselves. It works correctly.
But when i create a class library of this project and add it to a web application the objects become unable to read thier configuration data from app.config file.
So when i add that data to the web.config file it works fine.
But i want my objects be able to read configuration data from the app.config file. How can i do that?
Thanks.
|
|
|
|
|
Hi peshawarcoder,
To me, this sounds like a permission problem / path problem. Could you post the error that it gives ?
Cheers,
|
|
|
|
|
Class libraries cannot have config files. They are libraries of code that become part of the application project itself. Using the normal built-in methods, they must get their settting from the host applications config files, be it app.config for WinForms or web.config for ASP.NET. Outside of that, you'll have to implement your own configuration settings retrieval scheme.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|