Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

take information from childwindow RSS

6 replies

Last post Aug 14, 2009 01:40 PM by jijaxxx

(0)
  • jijaxxx

    jijaxxx

    Member

    22 Points

    54 Posts

    take information from childwindow

    Aug 14, 2009 10:07 AM | LINK

    hi,

    i want to save information input on objects in my childwindow.

    in my mainpage, when start the event currentselectchanged, i do this.

     

    private void Magrille_CurrentCellChanged_1(object sender, EventArgs e)

    {

    int X, Y;

     

    Y = Magrille.SelectedIndex;

    if (Y != -1)

    {

    X = Magrille.CurrentColumn.DisplayIndex;

    resawindow =
    new Resawindow();resawindow.reservation = new Reservation();

    resawindow.ord = Y;

    resawindow.Show();

    if (resawindow.reservation.confirmer)

    Reservation_blok(X, Y, resawindow.reservation);

    }

    }

    Resawindow is a Childwindow class.

    and:
     public void Reservation_blok(int X, int Y, Reservation reservation)

    {

    TextBox MyTextBox = new TextBox();

    double Top, Left;

    GeneralTransform objGeneralTransform = Magrille.TransformToVisual(Application.Current.RootVisual as UIElement);Point point = objGeneralTransform.Transform(new Point(0, 0));

    point.Y = point.Y + Magrille.RowHeight;

    Top = point.Y + Magrille.RowHeight * Y + Y;

    Left = point.X + X * Magrille.ColumnWidth.Value;

    MyTextBox.Height = Magrille.RowHeight * reservation.Duree;

    MyTextBox.Width = Magrille.ColumnWidth.Value;

    MyTextBox.SetValue(
    Canvas.LeftProperty, Left);

    MyTextBox.SetValue(Canvas.TopProperty, Top);

    MyTextBox.Visibility = Visibility.Visible;MyTextBox.Text = reservation.Name + " " + reservation.sujet;

    ControlleGrille.Children.Add(MyTextBox);

    MyTextBox.Background =
    new SolidColorBrush(Colors.Red);

    }

     

     

    and in my childwindow class

     

    private void OKButton_Click(object sender, RoutedEventArgs e)

    {

    reservation.Name = Name.Text;

    reservation.sujet = Subject.Text;

    reservation.Duree = Heure_fin.SelectedIndex + 1;

    reservation.confirmer =
    true;this.DialogResult = true;

    }

     

     

     

    Name, Subject are Childwindow TEXTBOX.

    the user enter his name and the subject (of the meetin). And i wanted to take this information, and use it in my mainpage (datagrid).

     

    Thx for help.

     

     

    Sorry, my english is very very poor.

  • Ardman

    Ardman

    Contributor

    5749 Points

    1484 Posts

    Re: take information from childwindow

    Aug 14, 2009 10:12 AM | LINK

    Create a class that has the properties Name etc. in and pass this into your Constructor of your Resawindow class.  So, your Reservation constructor becomes:

    public Reservation(new class here var)
    {
    ... your code

    }

    Then, you'll have this available to you from your calling function.

  • jijaxxx

    jijaxxx

    Member

    22 Points

    54 Posts

    Re: Re: take information from childwindow

    Aug 14, 2009 10:49 AM | LINK

    thx, but, it not solve my pb.

    1)  When i click in my Datagrid, the event CurrentCellchanged started (NO PROBLEM)

    2) In my event CurrenCellChanged, I open my ChildWindow ( register a meeting) (NO PROBLEM)

    3) in my ChilWindow, I enter Name and Subject, etc... (NO PROBLEM)

    4) I click on OKButton (on my childwindow) and my childwindow close itself... (NO PROBLEMO)

    5) I want the use information from my childwindow, and use it in my Datagrid (in my Mainpage) WHEN CHILDWINDOW CLOSE. (problem, i dont know if this event exist, and i dont know how do this)

     

    Thx

  • Ardman

    Ardman

    Contributor

    5749 Points

    1484 Posts

    Re: Re: Re: take information from childwindow

    Aug 14, 2009 10:51 AM | LINK

    If you were to add the class and then put the code to alter your DataGrid in the Window Closing/Closed event then you can make the amendments there.

  • jijaxxx

    jijaxxx

    Member

    22 Points

    54 Posts

    Re: Re: Re: take information from childwindow

    Aug 14, 2009 11:09 AM | LINK

    thx!!! I understand.

    But, in event Childwindow Closed/Closing, I wanted to modify my mainpage (datagrid).

    i cant do the relation in Childwindow Class. my datagrid doesnt exist, I think do this in Mainpage.Loaded. but my mainpage doesnt load.

     

    thx for your suggestion

  • Ardman

    Ardman

    Contributor

    5749 Points

    1484 Posts

    Re: Re: Re: Re: take information from childwindow

    Aug 14, 2009 11:16 AM | LINK

    You can set up your event handler on the MainPage.  See below:

    /// <summary>

    /// Executes when the Add New Client button is clicked

    /// </summary>

    /// <param name="sender">object: sender</param>

    /// <param name="e">e: RoutedEventArgs</param>

    private void AddNewClientButton_Click(object sender, RoutedEventArgs e)

    {

    AddNewClientWindow addNewClientWin = new AddNewClientWindow();addNewClientWin.Closed += new EventHandler(this.AddNewClientWin_Closed);

    addNewClientWin.Show();

    }

    /// <summary>

    /// Executes when the Add New Client window is closed

    /// </summary>

    /// <param name="sender">object: sender</param>

    /// <param name="e">e: EventArgs</param>

    private void AddNewClientWin_Closed(object sender, EventArgs e)

    {

    try

    {

    AddNewClientWindow client = (AddNewClientWindow)sender;

    // Check that we have an edited record and the DialogResult is true

    if (client.NewClient != null && client.DialogResult == true)

    {

    MyDomainContext context = (MyDomainContext)this.clientsDataSource.DomainContext;

    context.Clients.Add(client.NewClient);

    this.clientsDataSource.SubmitChanges();

    }

    }

    catch (Exception ex)

    {

    new ErrorWindow(ex.Message);

    }

    }

  • jijaxxx

    jijaxxx

    Member

    22 Points

    54 Posts

    Re: Re: Re: Re: Re: take information from childwindow

    Aug 14, 2009 01:40 PM | LINK

    perfect, absolutly perfect.

     

    Thx a lot.