我正在尝试使用唯一的数字音序器创建comboBox项目。
每按一次按钮,comboBox项应该像这样添加;
Item 1
Item 2
Item 3
...
如果我修改了第1项的名称;下一步单击必须将新项目命名为项目1。 我无法创建此基本音序器并需要您的帮助。
private void addNew_Click(object sender, EventArgs e)
{
//textBox1.Enabled = true;
//textBox1.Focus();
comboBox1.Items.Add("item", i);
}
答案 0 :(得分:1)
在表单构造函数下定义表单范围的计数器。像这样:
> at de.hybris.platform.core.Registry.startup(Registry.java:422)
> at de.hybris.platform.spring.HybrisContextLoaderListener.startRegistry(H
> ybrisContextLoaderListener.java:237)
> at de.hybris.platform.spring.HybrisContextLoaderListener.doInitWebApplic
> ationContext(HybrisContextLoaderListener.java:135)
> at de.hybris.platform.spring.HybrisContextLoaderListener.initWebApplicat
> ionContext(HybrisContextLoaderListener.java:125)
> at org.springframework.web.context.ContextLoaderListener.contextInitiali
> zed(ContextLoaderListener.java:106)
> at de.hybris.platform.spring.HybrisContextLoaderListener.contextInitiali
> zed(HybrisContextLoaderListener.java:80)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
> t.java:5016)
> at org.apache.catalina.core.StandardContext.startInternal(StandardContex
> t.java:5524)
> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
> java:1575)
> at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
> java:1565)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
> java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
> .java:617)
> at java.lang.Thread.run(Thread.java:748) INFO [localhost-startStop-1] [HybrisContextFactory] Initializing <<global>>
> Spr ing ApplicationContext took: (22.52 I¼s)
> de.hybris.platform.core.UninstantiableCoreApplicationContextException:
> Error cre ating Spring application context.
> at de.hybris.platform.core.AbstractTenant.doStartupSafe(AbstractTenant.j
> ava:728)
> at de.hybris.platform.core.AbstractTenant.doStartUp(AbstractTenant.java:
> 658)
> at de.hybris.platform.core.Registry.assureTenantStarted(Registry.java:63
> 9)
> at de.hybris.platform.core.Registry.activateTenant(Registry.java:700)
> at de.hybris.platform.core.Registry.setCurrentTenant(Registry.java:544)
> at de.hybris.platform.core.Registry.activateMasterTenant(Registry.java:6
> 07)
> at de.hybris.platform.core.Registry.startup(Registry.java:422)
> at de.hybris.platform.spring.HybrisContextLoaderListener.startRegistry(H
> ybrisContextLoaderListener.java:237)
> at de.hybris.platform.spring.HybrisContextLoaderListener.doInitWebApplic
> ationContext(HybrisContextLoaderListener.java:135)
> at de.hybris.platform.spring.HybrisContextLoaderListener.initWebApplicat
> ionContext(HybrisContextLoaderListener.java:125)
> at org.springframework.web.context.ContextLoaderListener.contextInitiali
> zed(ContextLoaderListener.java:106)
> at de.hybris.platform.spring.HybrisContextLoaderListener.contextInitiali
> zed(HybrisContextLoaderListener.java:80)
> at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
> t.java:5016)
> at org.apache.catalina.core.StandardContext.startInternal(StandardContex
> t.java:5524)
> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
> at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
> java:1575)
> at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.
> java:1565)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
> java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
> .java:617)
> at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.beans.FatalBeanException: Context hybris Global C
> ontext Factory couldn't be created correctly due to, Error creating
> bean with name 'defaultSolrServerService' defined in class path
> resource [global-solrserve r-spring.xml]: Invocation of init method
> failed; nested exception is de.hybris.p
> latform.solrserver.SolrServerException: Error while executing Solr
> start command for instance: [name: default, port: 8983]
> at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFacto
> ry.java:317)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ldSelf(HybrisContextFactory.java:189)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ld(HybrisContextFactory.java:175)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(H
> ybrisContextHolder.java:134)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisC
> ontextHolder.java:113)
> at de.hybris.platform.core.HybrisContextHolder.getAppCtxFactory(HybrisCo
> ntextHolder.java:164)
> at de.hybris.platform.core.HybrisContextHolder.getApplicationInstance(Hy
> brisContextHolder.java:90)
> at de.hybris.platform.core.AbstractTenant.createCoreApplicationContext(A
> bstractTenant.java:686)
> at de.hybris.platform.core.AbstractTenant.doStartupSafe(AbstractTenant.j
> ava:724)
> ... 20 more Error creating Spring application context. Shutting down hybris platform since t he system cannot be used without
> working Spring context... shutting down hybris registry.. INFO
> [Thread-1] [HybrisContextFactory] Initializing <<global>> Spring
> Applicati onContext took: (16.99 I¼s) ERROR [Thread-1] [JMXBeanLoader]
> Can't unregister jmxbeans on shutdown of the te nant <<master>>
> org.springframework.beans.FatalBeanException: Context hybris Global
> Context Fact ory couldn't be created correctly due to, Error
> creating bean with name 'defau ltSolrServerService' defined in class
> path resource [global-solrserver-spring.xm l]: Invocation of init
> method failed; nested exception is de.hybris.platform.sol
> rserver.SolrServerException: Error while executing Solr start command
> for instan ce: [name: default, port: 8983]
> at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFacto
> ry.java:317)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ldSelf(HybrisContextFactory.java:189)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ld(HybrisContextFactory.java:175)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(H
> ybrisContextHolder.java:134)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisC
> ontextHolder.java:113)
> at de.hybris.platform.core.Registry.getSingletonGlobalApplicationContext
> (Registry.java:1059)
> at de.hybris.platform.core.JMXBeanLoader.getMBeanRegistry(JMXBeanLoader.
> java:155)
> at de.hybris.platform.core.JMXBeanLoader.beforeTenantShutDown(JMXBeanLoa
> der.java:116)
> at de.hybris.platform.core.AbstractTenant.notifyTenantListenersBeforeShu
> tdown(AbstractTenant.java:1236)
> at de.hybris.platform.core.AbstractTenant.doShutdown(AbstractTenant.java
> :987)
> at de.hybris.platform.core.AbstractTenant.doShutDown(AbstractTenant.java
> :948)
> at de.hybris.platform.core.Registry.destroy(Registry.java:309)
> at de.hybris.platform.util.RedeployUtilities.shutdown(RedeployUtilities.
> java:74)
> at de.hybris.platform.util.RedeployUtilities$1.run(RedeployUtilities.jav
> a:38) error notifying tenant listener : null
> java.lang.NullPointerException
> at de.hybris.platform.jalo.JaloConnection$AbstractSynchronizedPropertyGe
> tter.get(JaloConnection.java:1142)
> at de.hybris.platform.jalo.JaloConnection.getExtensionManager(JaloConnec
> tion.java:1084)
> at de.hybris.platform.mobileservices.jalo.MobileManager.getInstance(Mobi
> leManager.java:130)
> at de.hybris.platform.mobileservices.jalo.MobileManager$1.beforeTenantSh
> utDown(MobileManager.java:92)
> at de.hybris.platform.core.AbstractTenant.notifyTenantListenersBeforeShu
> tdown(AbstractTenant.java:1236)
> at de.hybris.platform.core.AbstractTenant.doShutdown(AbstractTenant.java
> :987)
> at de.hybris.platform.core.AbstractTenant.doShutDown(AbstractTenant.java
> :948)
> at de.hybris.platform.core.Registry.destroy(Registry.java:309)
> at de.hybris.platform.util.RedeployUtilities.shutdown(RedeployUtilities.
> java:74)
> at de.hybris.platform.util.RedeployUtilities$1.run(RedeployUtilities.jav
> a:38) INFO [Thread-1] [HybrisContextFactory] Initializing <<global>>
> Spring Applicati onContext took: (22.52 I¼s) ERROR [Thread-1]
> [RegionCacheAdapter] Unable to clear cache. Failed on region nu ll.
> Last key null null org.springframework.beans.FatalBeanException:
> Context hybris Global Context Fact ory couldn't be created correctly
> due to, Error creating bean with name 'defau ltSolrServerService'
> defined in class path resource [global-solrserver-spring.xm l]:
> Invocation of init method failed; nested exception is
> de.hybris.platform.sol rserver.SolrServerException: Error while
> executing Solr start command for instan ce: [name: default, port:
> 8983]
> at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFacto
> ry.java:317)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ldSelf(HybrisContextFactory.java:189)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ld(HybrisContextFactory.java:175)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(H
> ybrisContextHolder.java:134)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisC
> ontextHolder.java:113)
> at de.hybris.platform.core.Registry.getSingletonGlobalApplicationContext
> (Registry.java:1059)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.getController(Region
> CacheAdapter.java:76)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.clear(RegionCacheAda
> pter.java:288)
> at de.hybris.platform.core.AbstractTenant.shutdownCache(AbstractTenant.j
> ava:1061)
> at de.hybris.platform.core.AbstractTenant.doShutdown(AbstractTenant.java
> :1003)
> at de.hybris.platform.core.AbstractTenant.doShutDown(AbstractTenant.java
> :948)
> at de.hybris.platform.core.Registry.destroy(Registry.java:309)
> at de.hybris.platform.util.RedeployUtilities.shutdown(RedeployUtilities.
> java:74)
> at de.hybris.platform.util.RedeployUtilities$1.run(RedeployUtilities.jav
> a:38) org.springframework.beans.FatalBeanException: Context hybris
> Global Context Fact ory couldn't be created correctly due to, Error
> creating bean with name 'defau ltSolrServerService' defined in class
> path resource [global-solrserver-spring.xm l]: Invocation of init
> method failed; nested exception is de.hybris.platform.sol
> rserver.SolrServerException: Error while executing Solr start command
> for instan ce: [name: default, port: 8983]
> at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFacto
> ry.java:317)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ldSelf(HybrisContextFactory.java:189)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ld(HybrisContextFactory.java:175)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(H
> ybrisContextHolder.java:134)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisC
> ontextHolder.java:113)
> at de.hybris.platform.core.Registry.getSingletonGlobalApplicationContext
> (Registry.java:1059)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.getController(Region
> CacheAdapter.java:76)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.clear(RegionCacheAda
> pter.java:288)
> at de.hybris.platform.core.AbstractTenant.shutdownCache(AbstractTenant.j
> ava:1061)
> at de.hybris.platform.core.AbstractTenant.doShutdown(AbstractTenant.java
> :1003)
> at de.hybris.platform.core.AbstractTenant.doShutDown(AbstractTenant.java
> :948)
> at de.hybris.platform.core.Registry.destroy(Registry.java:309)
> at de.hybris.platform.util.RedeployUtilities.shutdown(RedeployUtilities.
> java:74)
> at de.hybris.platform.util.RedeployUtilities$1.run(RedeployUtilities.jav
> a:38) INFO [Thread-1] [HybrisContextFactory] Initializing <<global>>
> Spring Applicati onContext took: (10.27 I¼s) ERROR [Thread-1]
> [RegionCacheAdapter] Unable to clear cache. Failed on region nu ll.
> Last key null null org.springframework.beans.FatalBeanException:
> Context hybris Global Context Fact ory couldn't be created correctly
> due to, Error creating bean with name 'defau ltSolrServerService'
> defined in class path resource [global-solrserver-spring.xm l]:
> Invocation of init method failed; nested exception is
> de.hybris.platform.sol rserver.SolrServerException: Error while
> executing Solr start command for instan ce: [name: default, port:
> 8983]
> at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFacto
> ry.java:317)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ldSelf(HybrisContextFactory.java:189)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ld(HybrisContextFactory.java:175)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(H
> ybrisContextHolder.java:134)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisC
> ontextHolder.java:113)
> at de.hybris.platform.core.Registry.getSingletonGlobalApplicationContext
> (Registry.java:1059)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.getController(Region
> CacheAdapter.java:76)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.clear(RegionCacheAda
> pter.java:288)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.destroy(RegionCacheA
> dapter.java:521)
> at de.hybris.platform.core.AbstractTenant.shutdownCache(AbstractTenant.j
> ava:1071)
> at de.hybris.platform.core.AbstractTenant.doShutdown(AbstractTenant.java
> :1003)
> at de.hybris.platform.core.AbstractTenant.doShutDown(AbstractTenant.java
> :948)
> at de.hybris.platform.core.Registry.destroy(Registry.java:309)
> at de.hybris.platform.util.RedeployUtilities.shutdown(RedeployUtilities.
> java:74)
> at de.hybris.platform.util.RedeployUtilities$1.run(RedeployUtilities.jav
> a:38) org.springframework.beans.FatalBeanException: Context hybris
> Global Context Fact ory couldn't be created correctly due to, Error
> creating bean with name 'defau ltSolrServerService' defined in class
> path resource [global-solrserver-spring.xm l]: Invocation of init
> method failed; nested exception is de.hybris.platform.sol
> rserver.SolrServerException: Error while executing Solr start command
> for instan ce: [name: default, port: 8983]
> at de.hybris.platform.core.HybrisContextFactory.build(HybrisContextFacto
> ry.java:317)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ldSelf(HybrisContextFactory.java:189)
> at de.hybris.platform.core.HybrisContextFactory$GlobalContextFactory.bui
> ld(HybrisContextFactory.java:175)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstanceCached(H
> ybrisContextHolder.java:134)
> at de.hybris.platform.core.HybrisContextHolder.getGlobalInstance(HybrisC
> ontextHolder.java:113)
> at de.hybris.platform.core.Registry.getSingletonGlobalApplicationContext
> (Registry.java:1059)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.getController(Region
> CacheAdapter.java:76)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.clear(RegionCacheAda
> pter.java:288)
> at de.hybris.platform.cache.impl.RegionCacheAdapter.destroy(RegionCacheA
> dapter.java:521)
> at de.hybris.platform.core.AbstractTenant.shutdownCache(AbstractTenant.j
> ava:1071)
> at de.hybris.platform.core.AbstractTenant.doShutdown(AbstractTenant.java
> :1003)
> at de.hybris.platform.core.AbstractTenant.doShutDown(AbstractTenant.java
> :948)
> at de.hybris.platform.core.Registry.destroy(Registry.java:309)
> at de.hybris.platform.util.RedeployUtilities.shutdown(RedeployUtilities.
> java:74)
> at de.hybris.platform.util.RedeployUtilities$1.run(RedeployUtilities.jav
> a:38) INFO [Thread-1] [DefaultClusterNodeManagementService]
> Unregistering assigned cl uster node id 0... <-- Wrapper Stopped
在您添加项目的方法中添加具有计数器值的项目,然后递增计数器。
int counter = 1;
public Form1()
{
InitializeComponent();
}