Smart Client software factory: extends the toolbar and adds a new view)

Source: Internet
Author: User

First, in the module project, modulecontroller. VB

This modulecontroller class has an empty method during generation.

Private sub extendtoolstrip () <br/> 'todo: add new items to the toolstrip in the shell. see the uiextensionsites collection in the workitem. <br/> '<br/> end sub 

It can be seen from the name that it is an extended toolbar, because the toolbar menu of the main form of scsf is dynamically generated, so we need to implement this method when we need to have our own toolbar.

 

Step 1: first define several constants in commandnames. VB in the constant folder

Namespace constants <br/> ''' <summary> <br/> ''' constants for command names. <br/> ''' </Summary> <br/> public class commandnames <br/> inherits infrastructure. interface. constants. commandnames <br/> '********************************** <br/> Public const adminform as string = "Administration" <br/> '********************** * *********** <br/> Public const eventlogform as string = "Event Log" <br/> '********* * *********************** <br/> end class <br/> end namespace 

 

Step 2: Register and run the subform function in the basic workitemcontroller.

 

''' <Summary> <br/> ''' registers the launch point. <br/> ''' </Summary> <br/> ''' <Param name = "text"> the text. </param> <br/> ''' <Param name = "commandname"> name of the command. </param> <br/> ''' <Param name = "icon"> the icon. </param> <br/> ''' <Param name = "hasaccess"> If set to <C> true </C> [has access]. </param> <br/> ''' <Param name = "sitename"> name of the site. </param> <br/> ''' <Param name = "toregister"> If set to <C> true </C> [To register]. </param> <br/> protected sub registerlaunchpoint (byval text as string, byval commandname as string, optional byval icon as image = nothing, optional byval hasaccess as Boolean = true, optional byval sitename as string = constants. uiextensionsitenames. modulesmenuitems, optional byval toregister as Boolean = false) <br/> dim element as toolstripmenuitem = new toolstripmenuitem () 'toolstripbutton = new toolstripbutton () <br/> if not icon is nothing then <br/> element. image = icon <br/> element. textimagerelation = textimagerelation. imagebeforetext 'textimagerelation. imageabovetext <br/> element. imagescaling = toolstripitemimagescaling. none <br/> end if <br/> element. TEXT = text <br/> element. tooltiptext = text <br/> element. enabled = hasaccess <br/> workitem. uiextensionsites (sitename ). add (element) <br/> workitem. commands (commandname ). addinvoker (element, "click") <br/> end sub 

 

Step 3: complete the extendtoolstrip method of the modulecontroller class

 

Private sub extendtoolstrip () <br/> 'todo: add new items to the toolstrip in the shell. see the uiextensionsites collection in the workitem. <br/> 'see: MS-help: // Ms. VSCC. v90/MS. vsipcc. v90/MS. practices. scsf.2008apr/scsf/html/02-04-340-showing_uielements.htm <br/> 'dim user as iusersecurityservice <br/> 'registerlaunchpoint (my. resources. moduletitle, commandnames. adminform, my. resources. administrationicon, isauthorize, sitename: = uiextensionsitenames. adminmodulesmenuitems) <br/> registerlaunchpoint (my. resources. moduletitle, commandnames. adminform, my. resources. administrationicon, true, sitename: = uiextensionsitenames. adminmodulesmenuitems) <br/> registerlaunchpoint (my. resources. eventlogtitle, commandnames. eventlogform, my. resources. I _info, isauthorize, sitename: = uiextensionsitenames. adminmodulesmenuitems) <br/> end sub 

 

In this example, uiextensionsitenames. adminmodulesmenuitems is a defined String constant.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.