我可以在myOlApp使用早期绑定的"类模块"中使用以下内容订阅Outlook事件.
'**Class Module - clsOutlookHandler **
Public WithEvents myOlApp As Outlook.Application
Private Sub Class_Initialize()
On Error Resume Next
Set myOlApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Set myOlApp = CreateObject("Outlook.Application")
Err.Clear
End If
On Error GoTo 0
End Sub
Run Code Online (Sandbox Code Playgroud)
为此,我需要确保检查Microsoft Outlook XX.X对象库的引用.
是否可以使用后期绑定订阅Outlook(或任何应用程序)事件?
我知道以下内容不起作用.VBA中有解决方法吗?
Public WithEvents myOlApp As Object
Run Code Online (Sandbox Code Playgroud) 使用VBA我可以使用以下内容创建一个包含3个不同选项卡的InternetExplorer对象
Option Explicit
Public Enum IE_READYSTATE
Uninitialised = 0
Loading = 1
Loaded = 2
Interactive = 3
complete = 4
End Enum
Sub Example_Click()
Dim ieApp As clsIE
'Create IE and login
If ieApp Is Nothing Then
Set ieApp = New clsIE
With ieApp
'IE Tab1
.IE.Visible = True
.IE.navigate "http://www.bbc.co.uk/news/"
Do While .IE.Busy Or Not .IE.readyState = IE_READYSTATE.complete: DoEvents: Loop
'IE Tab2
.IE.Navigate2 "http://www.bbc.co.uk", CLng(2048)
Do While .IE.Busy Or Not .IE.readyState = IE_READYSTATE.complete: DoEvents: Loop
'IE Tab3
.IE.Navigate2 …Run Code Online (Sandbox Code Playgroud) 我正在尝试将现有网站转换为Web应用程序项目,并且我在使配置文件工作时遇到很大问题.
网站项目中的代码隐藏的一个例子是
注册与 - 角色和profile.ascx.cs
// Add the newly created user to the default Role.
Roles.AddUserToRole(CreateUserWizard1.UserName, wsatDefaultRole);
// Create an empty Profile for the newly created user
ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);
// Populate some Profile properties. Values are located in web.config file
p.Company.Company = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txbOfficeName")).Text;
p.Company.Address = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txbOfficeAddress")).Text;
p.Company.City = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txbOfficeCity")).Text;
p.Company.State = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ddlStates")).SelectedValue;
p.Company.PostalCode = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txbOfficeZip")).Text;
p.Company.Phone = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txbContactPhone")).Text;
p.Company.Fax = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txbContactFax")).Text;
p.Preferences.Newsletter = ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ddlNewsletter")).SelectedValue;
// Save profile - must be done since we explicitly created …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Enumerable.OrderBy对List进行排序,因为最终我希望能够按多个字段进行排序.目前,如果我创建一个新变量var来保存结果视图,这似乎有效,这意味着(我认为)需要重新构建类型.
是否有一种方法可以在保留原始List变量和类型的同时对List进行排序多于1个字段?即我最终会_orderedbins得到类型的变量List<orderedbins>
以下是我目前的情况,但是从var test = ...开始的所有内容似乎都有点不对.
public class orderedBins
{
public string Bin { get; set; }
public int Order { get; set; }
}
List<orderedbins> _orderedbins = new List<orderedbins>();
foreach (string item in splitbins)
{
string[] spbinSetting = item.Split(',');
bool bchecked = bool.Parse(spbinSetting[1]);
int border = int.Parse(spbinSetting[2]);
if (bchecked == true)
{
_orderedbins.Add(new orderedbins { bin = spbinSetting[0], Order = border });
}
}
var test =_orderedbins.OrderBy(x => x.Order);
foreach (var item …Run Code Online (Sandbox Code Playgroud) 在Visual Studio中,我可以手动定义调试使用的指令
#define DEBUG
// ...
#if DEBUG
Console.WriteLine("Debug version");
#else
Console.WriteLine("Release version");
#endif
Run Code Online (Sandbox Code Playgroud)
有没有办法将其链接到解决方案配置,所以当我选择Debug/Release或自定义配置时,它会自动定义?
我有一个Webrowser,其中一些设置使用javascript进行了更改.我正在尝试使用此处的示例,但无法获得正确的语法
脚本看起来像这样
<div class="DisplayInput"><input type="radio" name="displaytype"
value="decimal" onclick="setdisplayType('decimal');" checked="checked"><a
href="javaScript:setdisplayType('decimal');"
onclick="s_objectID="javascript:setdisplayType('decimal');_1";return this.s_oc? this.s_oc(e):true">Decimal</a></div>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经尝试过这些并没有成功
this.webBrowser1.InvokeScript("setdisplayType");
this.webBrowser1.InvokeScript("setdisplayType('decimal')");
this.webBrowser1.InvokeScript("setdisplayType","decimal");
Run Code Online (Sandbox Code Playgroud) 我有一个数据表xData,该表的DateTime列精度为毫秒,我需要提取与确切时间相匹配的行(以毫秒为单位),但语法不正确。
我试过了
DateTime dt = timeStampList[i];
string str = dt.ToString("yyyy-MM-dd HH:mm:ss.fff");
DataRow[] result = xData.Select("TimeStamp2 = " + str);
foreach (DataRow row in result)
{
Console.WriteLine("{0}, {1}", row[0], row[1]);
}
Run Code Online (Sandbox Code Playgroud)
但
DataRow[] result = xData.Select("TimeStamp2 = " + str);
Run Code Online (Sandbox Code Playgroud)
导致错误:
语法错误:'16'运算符后缺少操作数。
我进行了搜索,但是大多数示例仅显示如何按日期而不是datetime毫秒进行选择。
我有一个方法,根据TreeView中单击的项目接收事件.
我可以以完全相同的方式向TreeView和TreeViewItem添加项目,因此尝试item根据state.sender类型分配为TreeView或TreeViewItem .但是,目前我能使其工作的唯一方法是首先将项目指定为对象.
private void ProcessEvent(Events.GetEventsResp resp, CustomAsyncStateContainer state)
{
object item = new object(); //must be a better way than this?
if (state.sender is TreeViewItem)
item = (TreeViewItem)state.sender;
else if (state.sender is TreeView)
item = (TreeView)state.sender;
//other code
}
Run Code Online (Sandbox Code Playgroud)
我认为这被称为拆箱?有没有更好的方法来做我正在尝试的事情?
编辑:下面是剩下的代码.在提出问题时我还没有完成它的写作,现在已经意识到object item = new object();在这种情况下不会起作用.
private void DisplayGetEvent(Events.GetEventsResp resp, CustomAsyncStateContainer state)
{
object node = new object();
if (state.sender is TreeViewItem)
node = (TreeViewItem)state.sender;
else if (state.sender is TreeView)
node = (TreeView)state.sender;
if …Run Code Online (Sandbox Code Playgroud) 我在Google上进行了广泛搜索,并且很难找到一个简单的示例来跟踪ItemsControl,我认为我需要能够执行以下操作.
我目前有一个Grid,其中包含一个包含Checkboxes的可滚动列表框,它使用以下XAML布局按预期工作
<Grid>
<ListBox ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding Selections}" Margin="12,22,12,94">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsChecked}"
Content="{Binding Path=Item.SelectionName}">
</CheckBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我现在想在每个Checkbox的右侧添加一个TextBox,使其与1个Checkbox水平对齐,每行1个Textbox.我以为我必须使用ItemsControl来允许两个控件但是使用ItemsControl如下所示我失去了滚动的能力
<Grid>
<ItemsControl ScrollViewer.VerticalScrollBarVisibility="Auto"
ItemsSource="{Binding Selections}" Margin="12,22,12,94">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsChecked}"
Content="{Binding Path=Item.SelectionName}">
</CheckBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
Run Code Online (Sandbox Code Playgroud)
此外,如果我尝试添加类似的文本框
<DataTemplate>
<CheckBox IsChecked="{Binding sChecked}" Content="{Binding Path=Item.BookieName}" />
<TextBox />
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
我收到一个错误 The object 'DataTemplate' already has a child and cannot add 'TextBox'
基本上,我希望它看起来像这样

任何人都可以给我一些关于如何在XAML中构建控件以获得我想要的布局的指针吗?
以下代码行
TreeView treeview = (TreeView)currentGroup.Content;
Run Code Online (Sandbox Code Playgroud)
列出错误
'TreeView'是'
System.Windows.Forms.TreeView'和'System.Windows.Controls.TreeView' 之间含糊不清的参考
我知道原因,因为我需要明确说明使用哪个引用,TreeView例如:
System.Windows.Controls.TreeView treeview = (System.Windows.Controls.TreeView)currentGroup.Content;
Run Code Online (Sandbox Code Playgroud)
这是什么最佳做法?TreeView如果通过多种方法广泛使用,是否有另一种(更整洁的)方法来定义哪个引用必须使用?
我正在尝试使用Watin 从此页面中选择第一个资产选择下拉列表中的项目,但无法获得任何工作.
此示例链接实际上具有相同的控件,并且代码完美运行Watin无法从选择列表中选择选项
但是,尝试应用相同的逻辑确实找到了正确的元素,但没有选择任何内容.有人可以帮助确定为什么这不起作用?
[Test]
public void ChosenTest()
{
IE myIE = new IE(true);
myIE.GoTo("http://www.marketoptions.com/trading-platform/");
myIE.SelectList(Find.ByClass("assetSelect chzn-ltr chzn-done")).WaitUntilExists();
string id = myIE.SelectList(Find.ByClass("assetSelect chzn-ltr chzn-done")).Id;
myIE.Div(id + "_chzn").Div(Find.ByClass("chzn-drop")).ElementWithTag("li", Find.ByIndex(7)).Click();
myIE.Div(id + "_chzn").Links[0].Spans[0].Click();
}
Run Code Online (Sandbox Code Playgroud)
编辑:看起来css样式有一些影响,不允许Watin单击或选择标准的html控件.如果有人能够生成一个可以从资产下拉菜单中选择项目的工作测试,并解释为什么当前代码不起作用,我将提供一笔赏金.
我在jsFiddle jsFiddle中有以下测试项目,它按预期运行,JSLint报告代码有效.
然后我将html复制并粘贴到记事本中的空白文本文件中并保存为randomfilename.html
当我单击html文件时,我看到文件选择器,我可以选择文件,但图表不会呈现.有什么想法吗?我尝试过IE,Chrome和Firefox,其中任何一个都没有图表.
谢谢
编辑:这是我现在在名为randomfilename.html的文本文件中
它不起作用
Chrome 21.0.1180.89 m 还是最新的firefox/IE对我来说?
<!DOCTYPE html>
<html>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<input type="file" id="files" name="file" />
<div id="container" style="height: 500px; min-width: 500px"></div>
<div id="testString"></div>
<script>
var dataString = new Array (
[1341187200000,592.52],[1341273600000,599.41],[1341446400000,609.94],[1341532800000,605.88],[1341792000000,613.89],[1341878400000,608.21],
[1341964800000,604.43],[1342051200000,598.90],[1342137600000,604.97],[1342396800000,606.91],[1342483200000,606.94],[1342569600000,606.26],
[1342656000000,614.32],[1342742400000,604.30],[1343001600000,603.83]);
function handleFileSelect(evt)
{
var files = evt.target.files; // FileList object
for (var i = 0, f; f = files[i]; i++)
{
var reader = new FileReader();
reader.onload = (function(reader)
{
return function()
{
var contents …Run Code Online (Sandbox Code Playgroud)