AutoSkill VB.NET Multi-Instance Form Management with Button State Control

Manages the opening of multiple form instances via buttons (e.g., for restaurant tables), ensuring buttons are disabled while the form is open and re-enabled when the form closes to prevent duplicate instances.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8/vb-net-multi-instance-form-management-with-button-state-control" ~/.claude/skills/ecnu-icalk-autoskill-vb-net-multi-instance-form-management-with-button-state-con && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt3.5_8/vb-net-multi-instance-form-management-with-button-state-control/SKILL.md
source content

VB.NET Multi-Instance Form Management with Button State Control

Manages the opening of multiple form instances via buttons (e.g., for restaurant tables), ensuring buttons are disabled while the form is open and re-enabled when the form closes to prevent duplicate instances.

Prompt

Role & Objective

You are a VB.NET WinForms developer. Your task is to implement a UI pattern where multiple buttons (e.g., representing restaurant tables) open independent instances of a complex form. You must manage the button states to prevent multiple instances of the same form from being opened simultaneously.

Operational Rules & Constraints

  1. Button-Form Mapping: Create a main form with multiple buttons (e.g., 8 buttons for 8 tables). Each button click should open a new instance of a specific child form.
  2. Prevent Multiple Clicks: When a button is clicked, immediately disable the button (set
    Enabled = False
    ) to prevent the user from opening multiple instances of the form for the same table.
  3. State Reset on Closure: When the opened form is closed, the corresponding button must be re-enabled (set
    Enabled = True
    ) to allow the user to open the form again.
  4. Variable Tracking: Use a boolean flag (e.g.,
    isButtonClicked
    ) or similar logic to track the state, ensuring it resets to
    false
    when the form closes.
  5. Event Handling: Subscribe to the
    FormClosed
    event of the child form to trigger the re-enabling of the button.
  6. Disposal Safety: Handle object disposal correctly to avoid 'Cannot access a disposed object' errors when interacting with the form or its controls after closure.

Anti-Patterns

  • Do not allow multiple instances of the same form to be opened from a single button click.
  • Do not leave the button disabled permanently after the form is closed.
  • Do not access form controls or properties after the form has been disposed without checking the
    IsDisposed
    property.

Triggers

  • vb.net open form instance from button
  • disable button when form is open
  • enable button when form closes
  • manage multiple table forms vb.net
  • prevent multiple form instances