如何在TreeView中选中/取消选中所有子项?当其中一项变为选中状态并且子项已选中/未选中时,可能发生了错误。
private void Form1_Load(object sender, EventArgs e)
{
treeView1.CheckBoxes = true;
treeView1.BeginUpdate();
treeView1.Nodes.Add("1111");
treeView1.Nodes[0].Nodes.Add("2222");
treeView1.Nodes[0].Nodes.Add("2222");
treeView1.Nodes[0].Nodes.Add("2222");
treeView1.Nodes[0].Nodes.Add("2222");
treeView1.Nodes[0].Nodes[1].Nodes.Add("3333");
treeView1.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("4444");
treeView1.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("4444");
treeView1.Nodes[0].Nodes[1].Nodes[0].Nodes.Add("4444");
treeView1.EndUpdate();
treeView1.ExpandAll();
}
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
treeView1.BeginUpdate();
foreach (TreeNode Node in e.Node.Nodes)
{
Node.Checked = e.Node.Checked;
}
treeView1.EndUpdate();
}
Run Code Online (Sandbox Code Playgroud) 我正在调用一个控制器方法,使用Url.action,
location.href = '@Url.Action("Display", "Customer", new { username = "abc",name = "abcdef",country = "India",email = "abc@hmail.com",phone = "9456974545"})';
Run Code Online (Sandbox Code Playgroud)
我的控制器方法是,
public void Display(string username, string name, string country, string email, string phone)
{ }
Run Code Online (Sandbox Code Playgroud)
在这个方法中,我只能得到第一个参数(username)的值.它没有获得传递的其他参数值.所有其他值均为null.
请建议我,什么错?
我正在开发一个控制台应用程序,它创建一个表单来提醒某些给定状态的用户 - 在稍后阶段,代码库将成为一个类库.
但是,现在,我需要显示表单(ShowDialog将是这里最好的方法,我猜)然后在表单关闭之前调用任意方法.
作为一个例子,我需要显示表单,设置标签控件的文本值,等待n秒,然后更改标签的值,然后关闭表单.我知道这听起来有点微不足道,但我正在尝试对设计进行概念验证.
我已经浏览了一下它看起来不可能,因为ShowDialog()要求我在调用方法/类之前继续通过代码列表之前关闭表单.
这是我到目前为止所拥有的:
PopUpForm myForm = new PopUpForm(string messageToDisplay);
myForm.ShowDialog();
//call myForm.someMethod() here, before the form closes
//dispose of the form, now that we've no use for it
myform.Dispose();
//target method in PopUpform class
public void someMethod()
{
lblText.Text = "Waiting for some reason";
//wait n number of seconds
lblText.Text = "Finished waiting. Form will now close";
//it doesn't matter if the form closes before the user can see this.
}
Run Code Online (Sandbox Code Playgroud)
看起来ShowDialog()不支持这种行为.我正在研究BackgroundWorker线程,但是想知道是否有人对此有任何建议,或者之前遇到过这个问题.
我正在为霍尼韦尔Dolphin 6100开发一个应用程序,霍尼韦尔Dolphin 6100是一款带有条形码扫描仪的移动计算机,它使用Windows CE 5.0,就像OS一样.
我想创建一个负责将excel文件转换为.csv文件的小应用程序.
在Win CE中有可能吗?如果有的话,对它有什么帮助吗?
先感谢您 !!
注意:我正在使用VS2008而我正在使用Windows 7.
我发现这令人惊讶,而且很烦人.
例:
Decode(”) => ”
Encode(”) => ”
Run Code Online (Sandbox Code Playgroud)
相关课程:
.NET 4: System.Net.WebUtility
.NET 3.5: System.Web.HttpUtility
Run Code Online (Sandbox Code Playgroud)
我可以理解一个网页可以是Unicode,但我的情况是输出不能是UTF8.
有什么东西(也许是一个HtmlWriter类)可以做到这一点,而我不必重新发明轮子?
替代方案:
string HtmlUnicodeEncode(string input)
{
var sb = new StringBuilder();
foreach (var c in input)
{
if (c > 127)
{
sb.AppendFormat("&#x{0:X4};", (int)c);
}
else
{
sb.Append(c);
}
}
return sb.ToString();
}
Run Code Online (Sandbox Code Playgroud) 我正在研究Visual Studio 2012环境中的C++代码.代码库不是很大(包含在大约10-12个源文件中).我项目中某些功能的执行时间很长(例如,REL模式下为10秒,DEBUG模式下为50秒)
现在在调试时,我经常需要查看在应用程序生命周期结束时执行的函数.有没有办法只为项目中的特定功能和/或文件禁用编译器优化.这将使我能够针对某些计算上广泛的功能进行优化执行
注意:我之前错误地提到了"调试符号"而不是"编译器优化".我基本上是在编译器优化时问这个问题,因为在使用断点调试时很难检查变量值.
我一直在开发一个控制台应用程序(C#/ .Net Framework 4.0/VS2012).我创建了一个SQL Server Compact数据库(*.sdf)并添加了一个连接字符串:
<connectionStrings>
<add name="Dispatcher.Properties.Settings.FakeDataSetConnectionString"
connectionString="Data Source=|DataDirectory|\FakeDataSet.sdf"
providerName="Microsoft.SqlServerCe.Client.4.0" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试执行以下代码时:
SqlConnection con = new SqlConnection();
con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Dispatcher.Properties.Settings.FakeDataSetConnectionString"].ToString();
con.Open();
Run Code Online (Sandbox Code Playgroud)
它在con.Open()中给出以下异常:
建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确,以及SQL Server是否配置为允许远程连接.(提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)
我在这里做错了什么?
SQL Server代理和SQL Server Browser都处于"已启动"状态.使用SQL Server Compact Edition时实际上是否重要?
这可能是一个基本问题,所以请提前道歉.
我有一个控制台应用程序,我想在Windows Server 2003上测试.
我在C#的4.0框架下在Release模式下构建了应用程序,并将bin文件夹的内容粘贴到windows server 2003目录下的文件夹中.
当我运行exe时,我收到以下错误:"无法从命令行或调试器启动服务.必须首先安装Windows服务(使用installutil.exe),然后启动ServerExplorer,...."
现在我想使用installutil.exe作为服务来安装此控制台应用程序.
任何人都可以告诉我如何.
谢谢.
我一直在测试这个缓存方法/代码:http: //code.activestate.com/recipes/498245-lru-and-lfu-cache-decorators/?c = 15348
在某些情况下,我得到这个(或类似的)错误:"AttributeError:'str'对象没有属性' module '"
这里是代码示例,这些工作正常:
if __name__ == '__main__':
@lru_cacheItem(maxsize=20)
def f(x, y):
return 3*x+y
domain = range(5)
from random import choice
for i in range(1000):
r = f(choice(domain), choice(domain))
print('Hits:{0}'.format(f.hits), 'Misses:{0}'.format(f.misses))
@lfu_cacheItem(maxsize=20)
def f(x, y):
return 3*x+y
domain = range(5)
from random import choice
for i in range(1000):
r = f(choice(domain), choice(domain))
print('Hits:{0}'.format(f.hits), 'Misses:{0}'.format(f.misses))
@lru_cacheItem(maxsize=20)
def myString(a, b):
return '{0} and {1}'.format(a, b)
a = 'crap'
b = 'shit'
for i in range(1000):
r …Run Code Online (Sandbox Code Playgroud) 我将使用aspnet_regiis.exe工具加密web.config中的连接字符串.
不知道如何在服务器上解密连接字符串,所以wana问,如果我在我的开发机器上加密并在服务器上部署,它会工作吗?或者它应该在将要执行的同一台机器上加密?
c# ×6
.net ×3
asp.net ×1
asp.net-mvc ×1
c++ ×1
caching ×1
controller ×1
html-encode ×1
iis-7 ×1
python ×1
smart-device ×1
treeview ×1
unicode ×1
url.action ×1
visual-c++ ×1
web-config ×1
windows-ce ×1
winforms ×1