|
Please tell me that you don't use default names. Tell me that you are using Form2 as an example only.
It is never good practice to leave default names for something - what is the purpose of Form2? Can you tell without opening the form up and having a look?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
i used form2 only for the example..i know that is bad naming if we use Form2 or Form1 for naming a form
|
|
|
|
|
That's OK then - now, lets make sure that the OP knows not to do this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: It is never good practice to leave default names for something - what is the purpose of Form2? Can you tell without opening the form up and having a look?
Pete O`Hanlon wrote: Tell me that you are using Form2 as an example only.
Which is actually a bad one, cause it would make the beginners think, that they would not need an instance of the form (which is per default named "Form2" as class name) to call ShowDialog.
And then will ask 10 min. later why they get a compile error.
All the best,
Martin
|
|
|
|
|
try use Form2.ShowDialog()
then you'll not have to set your first form to show after second form is closed
Regards,
TCim
|
|
|
|
|
|
i'm sorry .. Form2 just an example, not the name of the form
Regards,
TCim
|
|
|
|
|
OK, ok,
But why are you posting same answere twice?
All the best,
Martin
|
|
|
|
|
First i post a message..my post doesn't show in forum then i posted it again, then i get my new and old message show
Regard,
TCim
|
|
|
|
|
As Martin stated, you should use the ShowDialog method. Then, depending on the DialogResult from the form, you would reload the data (as it doesn't make sense to reload the data if you haven't actually done the save).
Suppose that you have a form called OptionsDialog which you are going to use to add some options into a program and that the details will be saved to the database when the user clicks OK. In this form, set the DialogResult of the OK button to OK.
In your parent form, you would call it with something like this:
private void AddOptions()
{
using (OptionsDialog dlg = new OptionsDialog())
{
if (dlg.ShowDialog(this) == DialogResult.OK)
{
ReloadOptions();
}
}
} I hope that this helps.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Good. My 5. But please make me clear on this
Pete O`Hanlon wrote: using (OptionsDialog dlg = new OptionsDialog())
What is this statement ?
How about using delegates to get the same result ? is it a good practice ?
|
|
|
|
|
N a v a n e e t h wrote: Pete O`Hanlon wrote:
using (OptionsDialog dlg = new OptionsDialog())
What is this statement ?
A "using"-block will Dispose and Close the form automatically after code block has finished!
So you don't have to worry for that.
N a v a n e e t h wrote: How about using delegates to get the same result ? is it a good practice ?
It depends of the problem and the way something has to be solfed.
In this case it would be neccesary if the programmer says, that ShowDialog should not be used (maybe because of aditional parallel interaction with an other form).
Than you would have to use Show(), and Form provides the delegates for that (Close and Closing)
All the best,
Martin
|
|
|
|
|
The using statement here means that I don't have to remember to call the Dispose() method on the form. Another way to do this would be:
OptionsDialog dlg = new OptionsDialog()
try
{
if (dlg.ShowDialog() == DialogResult.OK)
{
ReloadData();
}
}
finally
{
dlg.Dispose();
} The C# team provided the using command as a shortcut so that any type that implemented IDisposable could be automatically disposed. This feature was added to VB.NET in .NET2.
Using delegates is also a good way to do this, especially if you don't want to go the ShowDialog route. Suppose that you have a modeless dialog, delegates are a very good way to pass the information back.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks pete for making concept clear.
|
|
|
|
|
No problems, I'm glad to help.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks,
I hope it will work fine with that problem,
I'll let you know after applying it.
Thanks again
Nisha S.
|
|
|
|
|
Hi techies,
may i get a help regarding how to "Changing the Advertisement in a AdRotator control by setting a specific interval of time...?"
thanx & regards
Ramu Annamalai
|
|
|
|
|
Don't Cross Post in Multiple Forums.
SSK.
|
|
|
|
|
Vri SSK wrote: Don't Cross Post in Multiple Forums.
Didn't you do same, by telling him this in both forums?
All the best,
Martin
|
|
|
|
|
How to create a textbox in c++..? I want to create 3 textbox and a button, if u insert values to the 2 textbox(suppose 1st textbox "2" and 2nd textbox "4")and if click the button third textbox should display the reslut(2+4=6) Plse reply..
|
|
|
|
|
Post it in the Correct Forum.
SSK.
|
|
|
|
|
I'm sorry garga1,
this is c# forum, if u want to ask anything in c++ u should go to c++ forum
int a = Convert.ToInt32(Textbox1.Text);
int b = Convert.ToInt32(Textbox2.Text);
int c = a + b;
TextBox3.Text = c;
Regard,
TCim
|
|
|
|
|
Hi There,
I have to open Outlook window, rather specifically some particular window with in outlook using C#. For example, if a user of my application has to add a new task in the tasks list, or setup a new appointment, I want to allow my users to click on a button on Windows Form and access that particular window i.e. Add New Task Window, Add New Appointment Window etc.
I can do this using Outlook Object Library as well, but in my particular case I have to do this using the actual outlook windows. Well, if I'll be able to do that first, then i'll definitly show a list of the items in my windows form and then let the user click on a particular item and then edit in some outlook editor window.
Any help on this would be really appreciated.
Best Regards,
Shahzad
|
|
|
|
|
these r some of the links which will solve ur problem
http://weblogs.asp.net/cumpsd/articles/89697.aspx
http://dotnetjunkies.com/Tutorial/2E1EEEAF-C78A-4A38-A830-AC204B12DF83.dcik ----> specific to ur case
With Regards
Amjath
|
|
|
|
|
Thanks very much, Amjath, for the reply.
But, infact, I was looking something to open a specific window of the Outlook. As we can open Outlook itself by using Process class in the Diagnostics namespace. It just opens the main Outlook window, but I was looking for something which can directly open a particular window like Add New Task, Or if I select a particular task from a list it can open the details in the task editor window of the outlook.
The articles you have mentioned can help me do the stuff by coding, but I don't wanna code, I just wanna go to the specific window.
Regards,
Shahzad
|
|
|
|