Click here to Skip to main content
16,005,389 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan5-Apr-04 18:27
MeterMan5-Apr-04 18:27 
GeneralRe: Generating listbox based on dataset? Pin
Heath Stewart5-Apr-04 18:34
protectorHeath Stewart5-Apr-04 18:34 
GeneralRe: Generating listbox based on dataset? Pin
MeterMan5-Apr-04 21:14
MeterMan5-Apr-04 21:14 
GeneralChanging menu bars color Pin
MeterMan4-Apr-04 16:34
MeterMan4-Apr-04 16:34 
GeneralRe: Changing menu bars color Pin
Heath Stewart4-Apr-04 18:00
protectorHeath Stewart4-Apr-04 18:00 
GeneralRe: Changing menu bars color Pin
MeterMan4-Apr-04 19:09
MeterMan4-Apr-04 19:09 
GeneralMaking menu Item bring and kill focus Pin
MeterMan4-Apr-04 16:28
MeterMan4-Apr-04 16:28 
GeneralRe: Making menu Item bring and kill focus Pin
Heath Stewart4-Apr-04 17:52
protectorHeath Stewart4-Apr-04 17:52 
Showing and hiding user controls or forms will not make dispose of them. Just use a couple of fields in your class to keep a reference to them, the same as the designer does when you design your form:
public class MyForm : Form
{
  private Add addControl;
  private Delete deleteControl;
  public MyForm()
  {
    addControl = new Add();
    deleteControl = new Delete();
    // If you want, add them to the Controls collection now.
  }
  private void addMenu_Click(object sender, EventArgs e)
  {
    Controls.Remove(deleteControl);
    Controls.Add(addControl);
    // Or use deleteControl.Hide() and addControl.Show()
  }
  private void deleteMenu_Click(object sender, EventArgs e)
  {
    Controls.Remove(addControl);
    Controls.Add(deleteControl);
    // Or use addControl.Hide() and deleteControl.Show()
  }
}
This is a simple example, but hopefully gives you some idea that you don't dispose of controls when showing/hiding them, or adding/removing them from the parent's Controls collection property.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Making menu Item bring and kill focus Pin
MeterMan4-Apr-04 19:12
MeterMan4-Apr-04 19:12 
GeneralRe: Making menu Item bring and kill focus Pin
Heath Stewart4-Apr-04 19:18
protectorHeath Stewart4-Apr-04 19:18 
GeneralRe: Making menu Item bring and kill focus Pin
LongRange.Shooter5-Apr-04 9:18
LongRange.Shooter5-Apr-04 9:18 
GeneralShockwave Flash in Windows Application!! Pin
Imad_4u4-Apr-04 15:40
Imad_4u4-Apr-04 15:40 
GeneralRe: Shockwave Flash in Windows Application!! Pin
Heath Stewart4-Apr-04 17:45
protectorHeath Stewart4-Apr-04 17:45 
GeneralRe: Shockwave Flash in Windows Application!! Pin
Jeremy Kimball5-Apr-04 3:44
Jeremy Kimball5-Apr-04 3:44 
GeneralControl Windows Key on Keyboard Pin
Member 6910894-Apr-04 15:04
Member 6910894-Apr-04 15:04 
GeneralRe: Control Windows Key on Keyboard Pin
Heath Stewart4-Apr-04 17:39
protectorHeath Stewart4-Apr-04 17:39 
GeneralRe: Control Windows Key on Keyboard Pin
Member 6910895-Apr-04 7:13
Member 6910895-Apr-04 7:13 
GeneralStartUp Folder?! Pin
Morten Kristensen4-Apr-04 14:28
Morten Kristensen4-Apr-04 14:28 
GeneralRe: StartUp Folder?! Pin
Heath Stewart4-Apr-04 17:29
protectorHeath Stewart4-Apr-04 17:29 
GeneralRe: StartUp Folder?! Pin
Morten Kristensen5-Apr-04 0:28
Morten Kristensen5-Apr-04 0:28 
GeneralAutoScroll on tabpage and animated cursor Pin
Flack4-Apr-04 11:18
Flack4-Apr-04 11:18 
GeneralRe: AutoScroll on tabpage and animated cursor Pin
Heath Stewart4-Apr-04 12:59
protectorHeath Stewart4-Apr-04 12:59 
GeneralRe: AutoScroll on tabpage and animated cursor Pin
Flack4-Apr-04 17:38
Flack4-Apr-04 17:38 
GeneralRe: AutoScroll on tabpage and animated cursor Pin
Heath Stewart4-Apr-04 17:43
protectorHeath Stewart4-Apr-04 17:43 
GeneralFlickering Controls and Non Transparent Corners Pin
Tristan Rhodes4-Apr-04 10:36
Tristan Rhodes4-Apr-04 10:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.