我有一些字符串:
"rose with ribbon"
"roses in concrete"
"roses on bed"
Run Code Online (Sandbox Code Playgroud)
我必须编写一个程序来查找存在优先单词的字符串
例如:找到"开"的字符串,所以我只需要"床上的玫瑰".
我用过这段代码:
foreach (KeyWord key in cKeyWords)
{
foreach (string word in userWords)
{
if (key.keyWord.IndexOf(word) != -1)
{
ckeyList.Add(key);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到了所有字符串,因为IndexOf在所有字符串中都找到了"on".
有没有其他解决方案在字符串中找到单独的单词而不分割?也许有可能使用Linq或Regex?但是我不擅长使用它们,所以有任何例子会很好.
我有一个RichTextBox作为消息正文,我需要使用富文本正文创建一个新邮件。我的代码是我如何实现的:
MemoryStream ms = new MemoryStream();
MemoEditBody.SaveDocument(ms, DevExpress.XtraRichEdit.DocumentFormat.Rtf);
byte[] RTFBody = ms.ToArray();
email.oMsg.RTFBody = RTFBody;
Run Code Online (Sandbox Code Playgroud)
OutlookEMail email;
public MailItem oMsg;
Run Code Online (Sandbox Code Playgroud)
问题:使用2010 Outlook-正常工作;使用2007 Outlook-此代码引发异常(AccessViolationException: Attempted to read or write protected memory)有人可以建议如何使用2007 Outlook解决此问题吗?
PS使用:Visual Studio 2010 DevExpress
它在两台计算机上进行了测试,它们几乎是相同的(相同的窗口,相同的框架,只有一个具有Outlook 2007,另一个具有2010),因此Outlook版本中的问题占80%。
我有webproject,其中包含src/main/webapp文件夹中的图像.我想将图像放在磁盘上的不同文件夹中.但我不知道如何管理访问此图像的请求.我应该创建一些httpServlet类似于此处显示的内容:http://balusc.omnifaces.org/2007/07/fileservlet.html
或者当我使用Spring MVC和java配置时,有更合适和更简单的方法.
期待您的建议.
我得到这样的异常:
javax.servlet.ServletException: Could not resolve view with name 'htmlviews/index.html' in servlet with name 'dispatcher'
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1211)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Run Code Online (Sandbox Code Playgroud)
当我尝试连接到完全Java配置的Spring Web服务时。
我的配置类:
@Configuration
@EnableWebMvc
@ComponentScan({"config", "controller"})
public class MyWebConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/htmlviews/**").addResourceLocations("/htmlviews/");
}
}
Run Code Online (Sandbox Code Playgroud)
初始化器:
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[]{MyWebConfig.class};
}
protected Class<?>[] getServletConfigClasses() {
return null;
}
protected String[] getServletMappings() {
return new String[]{"/"};
}
}
Run Code Online (Sandbox Code Playgroud)
和控制器:
@Controller
public …Run Code Online (Sandbox Code Playgroud) 我正在使用devexpress和visualstudio 2010.我有LookUpEdit控件,我想选择值,但是用指定的格式显示它:有一个我用buttonEdit的例子:
CurrentEvent.fkVersion = selectedVersion;
m_cVersionButtonEdit.EditValue= CurrentEvent.fkVersion.FormattedProduct;
m_cVersionButtonEdit.Refresh();
Run Code Online (Sandbox Code Playgroud)
"selectedVersion"是按下按钮后我在对话框中选择的对象.
现在我必须这样做,但使用lookupEdit并从dropDownlist中选择版本.那么问题是如何获得选定值?
需要帮助从另一个班级调用事件。我有已声明事件的课程:
public class MxPBaseGridView : GridView
{
public event AddNewItemsToPopUpMenuEventHandler AddNewItemsToPopUpMenu;
...
}
Run Code Online (Sandbox Code Playgroud)
我需要从中调用事件的另一个类具有方法和“AddNewItemsToPopUpMenuEventHandler”委托
public delegate void AddNewItemsToPopUpMenuEventHandler(PopupMenuShowingEventArgs e);
public static class GridViewUtils
{
public static void gridView_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
{
if (e.MenuType != DevExpress.XtraGrid.Views.Grid.GridMenuType.Row)
{
if (menu != null)
{
if (sender is MxPBaseAdvBandedGridView)
{
MxPBaseAdvBandedGridView currentGrid = sender as MxPBaseAdvBandedGridView;
...
currentGrid.AddNewItemsToPopUpMenu();
if (currentGrid.AddNewItemsToPopUpMenu != null) //there i need to call event
currentGrid.AddNewItemsToPopUpMenu(e); // how you understand it doesn't work
}
Run Code Online (Sandbox Code Playgroud)
那么做同样的工作的正确方法是什么?
有人可以建议如何将注册表中一个子类别的内容复制到另一个子类别的最佳方法吗?
例如,我们有:
HKEY_CURRENT_USER.Software.MyProgram.ver_1
Run Code Online (Sandbox Code Playgroud)
并运行函数检查,如果没有ver_2,那么创建... MyProgram.ver_2并复制所有内容... MyProgram.ver_1.
接收"java.lang.reflect.invocationtargetexception"调用date(String)构造函数的实例.
码:
Constructor constr = fieldType.getConstructor(String.class);
if (constr != null) {
val = constr.newInstance(val.toString()); // here is exeption
}
fieldType = java.util.Date;
val.getclass() = java.sql.Date,
val.toString() = 2014-05-19
constr [is not null] = java.util.Date(java.lang.String);
Run Code Online (Sandbox Code Playgroud)
也许有人可以帮我解决问题,如何正确调用构造函数?
我的代码更改了导航栏项的标题:
OverviewOrgan_NavBarHelper cNavBarHelper = new OverviewOrgan_NavBarHelper(Organization);
foreach (NavBarItem item in GetNavigationBar.Items)
{
string cCaption = cNavBarHelper.UpdateNavBarItemCaption(item);
item.Caption = cCaption;
}
Run Code Online (Sandbox Code Playgroud)
现在它在主线程上,但我必须将它移动到另一个线程.我知道UI不应该从另一个威胁改变,然后它就会被创建,所以我想到了使用BackgroundWorker.事实上,我不是在使用线程,有人可以为我的任务提出最佳解决方案吗?
有人可以提出实现目标的最佳方法吗?
所以,我有一个带有三个按钮的表单.我想要的是,根据按下面板上的按钮应该显示不同的控件(用户控件).我以一种简单的方式做到了这一点:所有都是从头开始添加的,我只是改变了可见性.但更好的是,如果有人能提出更合适的方法,因为不需要从头开始创建对象.