Several Dockable Windows working together as one add-in

2134
1
06-02-2011 06:28 AM
CamiloPedraza
New Contributor
Hi,

I'm working with add-ins and I have a button activates a main and first dockable window. Operations are done there and with the event of other button, another window should be shown to the user. Everything is correct until the second window is shown. With the information selected in the first one, i have to populate the controls but i doesn't seem to work, even with a complete refresh method.

Here's my the code to switch windows:

private void BtnProperties_Click(object sender, EventArgs e)
        {           
            if (!this.cbRuta.SelectedValue.ToString().Equals("Seleccione una manzana"))
                InitiatesUsers();
            else
                MessageBox.Show("Por favor seleccione una manzana", "Catastro Distrital", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }


protected void InitiatesUsers()
{
            string whereClause = "LOTLOTE_ID = '" + this.cbRuta.SelectedValue.ToString() + "'";
            //IFeatureClass ftClassPredios = this.connEstatement.OpenFeatureClass(workspaceConn, "DBO.LOTE", whereClause, "DBO.LOTE");

            DWUsers usersInit = new DWUsers();

            usersInit.SetProperties(connEstatement, workspaceConn, mapGeneral);// I set the properties of the previous window in the current.
            usersInit.LoadPredios(ftClassPredios); // Load the control.

            BtnActivacionLPC.ChangeWindowVisibility(ThisAddIn.IDs.DWInicio, false, this.Width, this.Height);
            BtnActivacionLPC.ChangeWindowVisibility(ThisAddIn.IDs.DWUsers, true, this.Width, this.Height);

        }

public void LoadPredios(IFeatureClass ftClassPredios)
        {
            DataTable dtPredios = new DataTable();
            CreateObjects objBL = new CreateObjects();
            dtPredios = tabletest(); // The table gets the correct values.

            this.listPredios.DataSource = dtPredios;           
            this.Refresh();          

        }

        public static void ChangeWindowVisibility(String WindowID, bool OnOff, int width = 300, int height = 500)
        {
            IDockableWindow dockNonStatic = null;           
            SetupDockableWindow(ref dockNonStatic, WindowID);
           
            if ((dockNonStatic.Name == WindowID) && (dockNonStatic.IsVisible() != OnOff))
            {               
                dockNonStatic.Show(OnOff);               
            }
            ResizeDockableWindow(dockNonStatic, width, height);
        }


Facts:

-If I set the datasource in the constructor of the second window, it works fine.
-Controls populate well if the instruction is set in the events of the first window.

Any help would be appreciated!!


Thanks.
0 Kudos
1 Reply
CamiloPedraza
New Contributor
It's a matter of referencing the object that will point to the docakable window that has been created. When i say DWUsers usersInit = new DWUsers(); I'm creating a new object, that will not point to the existing window. The problem now, how do i reach the existing object?
0 Kudos