devxlogo

Order Objects Constructed on a Window

Order Objects Constructed on a Window

Question:
I have a number of datawindows in a window. In a post-construct event I am making a call to another datawindow. Every so often when I open the window I get an error saying that the reference to the second datawindow is invalid. I think this is because the second datawindow has not been created yet. How can I adjust the order of the creation of the objects?

Answer:
You are correct in your assumption that the datawindow is not constructed and is causing your problem. If you move the code to the parent level (i.e. window) you will not get this problem.

The sequence in which the controls is created is based on their layering within the window painter. You could make sure this sequence is always correct but it is better practice not to rely on this behavior.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist