Form.Load????

I have a Form that load with some default data that comes from an object....when i change the default code my information does not change even though i have the functionality for changing in the Form.Load method.....Would there be any reason the form.Load would be called if the form is closed and re-opened from a parent form

this.cboStartingPoint.SelectedValue = this._VendorDetail.StartID;

this.cboEndingPoint.SelectedValue = this._VendorDetail.EndID;

if i change the value of the selectedvalue on the underlying object my information in this form does not change....it only changes when i open the form for the first time.....can anyone help out with this




Answer this question

Form.Load????

  • mr4100

    Where did you put the above two code lines At what points during runtime do you expect the above lines to execute again

    --
    SvenC


  • Maxncl

    Yes I want the Load to be called everytime i do Show/ShowDialog So what do u think i should do to solve this issue

  • grnr_r

    why cant you move the code in the Form Load to a function and call the function whenever you call the show/showdialog do you have any dificulties in doing that

  • Secsi

    If you apply Show/ShowDialog on the same instance again and again the Load wont be called except for the first time.

    Do you want the code inside the Load to be called evertime you call the Show/ShowDialog

    You may try moving your code from the Load to a new function and calling the function as necessary, if it not affects your business logic.



  • CBuilder

    Right my form.Load is not being called the 2nd time here is how i instanitate the form...

    public static void DisplayVendorDetails(System.Windows.Forms.Form ParentForm,Tracking.BusinessObjects.VendorOrderLegDetail _VendorLeg, int num)

    {

    Tracking.UI.MainWindows.VendorOrderLegDetailsForm frmVendorLeg = new VendorOrderLegDetailsForm();

    frmVendorLeg._VendorDetail = _VendorLeg;

    frmVendorLeg.LoadVendorObjectToForm();

    frmVendorLeg.ShowDialog(ParentForm);

    }



  • kart

    You are using ShowDialog to show the form and you must know that a form opened with ShowDialog is kept in memory even after it's closed...

    When you open a Form with Show() method, its called Modal Less Dialog and when you close a Modal Less Dialog its disposed of automatically.

    When you open a Form with ShowDialog() method, its called Showing form Modally and when you close a Modal Form it is kept in memory until you explicitly call the Dispose method on it. So the Chances are there that when you close your form after showing it with ShowDialog() the old instance is made active from the meory and which was already done Load when it was shown first time so Load even doesnot call again.

    The simplest thing I can ask you to try is to put a Dispose on the form right after the line which is Showing form with ShowDialog()

    example:

    frmVendorLeg.ShowDialog(ParentForm);

    frmVendorLeg.Dispose();

    I hope this will work just fine but even if your are still having a problem then just put another line after dispose

    frmVendorLeg = null;

    I hope this will solve your problem!

    Best Regards,

    Rizwan Ahmed



  • Devan1247

    If i understand your problem correctly, It is that the Form Load is not called for the sencond time.

    What method do you use to open the form again do you destroy the previous instance of the form and instantiate again



  • Form.Load????