Container control

New to container controls. I create one, put a pushbutton on it which calls a method from the window I place the container control onto. It won’t accept the method call without preceding it with the window name. IOW, it doesn’t inherit the window (did I say that right?).

Am I missing something or will I need to preface each method call on containers with the window name?

You’re breaking the rules here. You should insulate your containers from the outside world. The window communicates with the container via predefined methods on the container. The container communicates with the window by raising Events that the window implements. In other words, you define an API that controls how the window and the container interact.

Hm. Things just got real … complicated. The reason I’m even experimenting with container controls is my window is loaded with controls: it’s a layout window for a puzzle editor. I have a lot of textfields, buttons, etc. which all provide data for the puzzle to be laid out. Two days ago my program crashed costing me two days of work. Yesterday, after tediously duplicating my work, it crashed again. When I say crashed, I mean that I can no longer load the program file.

I speculated that maybe it’s because I have overloaded the window. I can’t find anything online that tells me there is a limit to controls on a window, but the crashes happened after I added two more checkboxes.

So I thought maybe containers might help. But since I don’t understand much of what you said, I’m not sure I want to go that route. In case you haven’t noticed, I’m an amateur programmer (teacher by trade) who came from the BASIC of the 1980s. This means 1) I’m old and 2) I’m hobbled by the past (they go together, don’t they?).

Anyway, I’ll keep messing with it. But how come things will work if I simply direct the button to the method on the window where it’s located? Is that a no-no too?

Here’s the window I’m developing …

(Don’t know if the image is going to show …

Not really that complicated, Mark. Just a concept you’re new to. (BTW - a week from Fri I’ll turn 69, so I don’t want to hear from “too old” :wink:
You put whatever controls you like on your Container Control (CC). You drag the CC to your window and place it. Give it a name. Let’s call it myCC. Now, when the window needs to communicate with your CC, you create a method on the CC. Let’s say “SetButtons”. And have it accept a param As string. Then when the window needs to set a button name on the CC, you call myCC.setButtons(“BtnName”)
Now, user pushed a button on the CC and the containing window needs to know that happened. You create a new “Event Definition” on your CC, let’s call it “buttonPushed”. That’s all you do on the CC. Go back to your Window, find the control “myCC” and implement a new event. You will see that your “buttonPushed” is now one of the options. You add that event and put code in it to do whatever.
The neat thing about this is that, if you move your CC to another window, you can implement that “buttonPushed” in a completely different way with a minimum of hassle.
Good luck.

Thanks, Roger. I’m gonna give it a whirl. I think I actually understand what you just wrote. And pretty clear writing for a soon-to-be 69-year-old. I’m 64 and my wife still needs me and feeds me (well, feeds me at least).

Looks like I also need to employ a RaiseEvent in the cc.

Getting there …

If you are just needing to keep a “fence” around groups of controls… how about using a “GroupBox” with a blank title instead?

I only ever use container controls when I am making a custom control class,

Dave,

Yeah, I sorta already did that. I used rectangles as a groupbox because I liked the look better. But what sent me on this whole mission is my program was crashing. If you can see that picture I inserted above, you can get an idea of how many controls I have on the window. Do you think this might be overloading the system? Because when I add a couple checkboxes, that’s when things fail. Actually, the first failure happened while debugging and trying to view strings as different various encodings.

If it’s a different issue, I’d be more than happy to dispense with the container controls because they are a bit of work (at least for me at this point).

The number of controls shouldn’t be an issue… and I will “assume” your crossword area is really a single canvas and not a boatload of little squares???

Yep, it’s a single canvas.

There’s probably something else causing the crashes. But I don’t know what and hence my quest to simplify the construction of the page. The container controls do seem to make the navigator tidier. They just seem to be a lot of extra work (and I still don’t quite understand them that well).