Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / November 2005

Tip: Looking for answers? Try searching our database.

Form designer cannot respond command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
allen pan - 03 Nov 2005 02:58 GMT
I write a simple form designer in vs2005. I can add and edit controls on
this designer. but when I delete a control, it can not repond.

the code like this:

   public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
       }

       private void Form1_Load(object sender, EventArgs e)
       {
           DesignSurface surface = new DesignSurface();
           surface.BeginLoad(typeof(Form));
           Control view = (Control)surface.View;
           view.Dock = DockStyle.Fill;
           this.splitContainer1.Panel1.Controls.Add(view);
           this.propertyGrid1.SelectedObject =
surface.ComponentContainer.Components[0];

           toolBoxService = new DemoToolboxService();

           toolBoxService.ToolBox = new ListBox();

           toolBoxService.ToolBox.Items.Add("Point");
           toolBoxService.ToolBox.Items.Add(new
ToolboxItem(typeof(Button)));
           toolBoxService.ToolBox.Items.Add(new
ToolboxItem(typeof(TextBox)));
           toolBoxService.ToolBox.Items.Add(new
ToolboxItem(typeof(Label)));
           toolBoxService.ToolBox.Items.Add(new
ToolboxItem(typeof(TabControl)));
           toolBoxService.ToolBox.Items.Add(new
ToolboxItem(typeof(StatusBar)));

           toolBoxService.ToolBox.Dock = DockStyle.Fill;
           this.panel1.Controls.Add(toolBoxService.ToolBox);

           menuCommandService = new MenuCommandService(surface);
           IServiceContainer container =
surface.GetService(typeof(IServiceContainer)) as IServiceContainer;

           if (container != null)
           {
               container.AddService(typeof(IToolboxService),
toolBoxService);
               container.AddService(typeof(IMenuCommandService),
menuCommandService);
           }

          selectionService = surface.GetService(typeof(ISelectionService))
as ISelectionService;
           selectionService.SelectionChanged += new
EventHandler(selectionService_SelectionChanged);
       }

       void selectionService_SelectionChanged(object sender, EventArgs e)
       {
           object[] selection;
           if (selectionService.SelectionCount == 0)
               propertyGrid1.SelectedObject = null;
           else
           {
               selection = new object[selectionService.SelectionCount];
               selectionService.GetSelectedComponents().CopyTo(selection,
0);
               propertyGrid1.SelectedObjects = selection;
           }

       }

       private DemoToolboxService toolBoxService;
       private ISelectionService selectionService;
       private MenuCommandService menuCommandService;

       private void deleteToolStripMenuItem_Click(object sender, EventArgs
e)
       {
           menuCommandService.GlobalInvoke(StandardCommands.Delete);
       }
   }

thank!
"Jeffrey Tan[MSFT]" - 03 Nov 2005 12:57 GMT
Hi Allen,

I will spend a little more time in this issue, I will reply to you ASAP.
Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.