我开始知道通过添加TreeView.BeginUpdate可以防止树视图的闪烁,但是当我将它添加到我的项目中时,我的treeview的所有节点都消失了,任何机构都可以告诉我它为什么会发生,这里是我使用TreeView的代码片段.BeginUpdate和TreeView.EndUpdate
TreeNode treeNode = new TreeNode("Windows");
treeView1.Nodes.Add(treeNode);
//
// Another node following the first node.
//
treeNode = new TreeNode("Linux");
treeView1.Nodes.Add(treeNode);
//
// Create two child nodes and put them in an array.
// ... Add the third node, and specify these as its children.
//
TreeNode node2 = new TreeNode("C#");
TreeNode node3 = new TreeNode("VB.NET");
TreeNode[] array = new TreeNode[] { node2, node3 };
//
// Final node.
//
treeNode = new TreeNode("Dot Net Perls", array);
treeView1.Nodes.Add(treeNode);
Run Code Online (Sandbox Code Playgroud) 我正在使用StreamWriter类进行文件操作,这段代码中是否有任何我没有看到的问题?
比如我需要将它放入一个try catch finally区块吗?
StreamWriter sr = new StreamWriter(streamFolder);
sr.Write(details);
File.SetAttributes(streamFolder, FileAttributes.Hidden);
sr.Close();
Run Code Online (Sandbox Code Playgroud) Installshield将创建软件包,可以是msi或rpm等.Windows安装程序还会创建msi和rpm文件吗?或者这是Windows操作系统中嵌入的工具,它是运行msi文件所必需的,这是否正确?我所说的我们将使用安装盾创建msi文件,然后我们将给客户,他们将在其操作系统中嵌入的Windows安装程序的帮助下安装msi并生成exe文件,这是否正确?
我有一个树视图,基于树视图的项目,我在右侧有列表视图。因此,几乎UI是我们Windows Explorer的一种外观。所以现在我面临的问题是,当我从右侧的列表视图中删除大量对象时,左侧的树形视图被部分绘制了(我可以说很小的一部分)。当我从VS IDE附加CLR响应时,它指向行sampletree.EndUpdate(); 除了内存不足。当我在列表视图中添加下一个项目时,一切都正常了,这意味着树形视图已完全绘制完毕,异常是
System.OutOfMemoryException occurred
Message=Out of memory.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
at System.Drawing.Font.ToLogFont(Object logFont)
at System.Drawing.Font.ToHfont()
at System.Windows.Forms.Control.FontHandleWrapper..ctor(Font font)
at System.Windows.Forms.OwnerDrawPropertyBag.get_FontHandle()
at System.Windows.Forms.TreeView.CustomDraw(Message& m)
at System.Windows.Forms.TreeView.WmNotify(Message& m)
at System.Windows.Forms.TreeView.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmNotify(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& …Run Code Online (Sandbox Code Playgroud) 我想重新启动名为"Spooler"的窗口服务我做了以下代码,但没有运气,任何机构都知道出现了什么问题?代码是
using System.ServiceProcess;
ServiceController service = new ServiceController("Spooler");
if ((service.Status.Equals(ServiceControllerStatus.Stopped)) ||
(service.Status.Equals(ServiceControllerStatus.StopPending)))
{
service.Start();
}
else
{
service.Stop();
service.Start();
}
Run Code Online (Sandbox Code Playgroud)
例外是
"System.InvalidOperationException:无法在计算机上启动服务假脱机程序.".---> System.ComponentModel.Win32Exception:服务实例已在运行
---内部异常堆栈跟踪结束---
在System.ServiceProcess.ServiceController.Start(String [] args)
在System.ServiceProcess.ServiceController.Start()
at servicerestart.Form1.button1_Click(Object sender,EventArgs e)在D:\ samplecodes\servicerestart\servicerestart\Form1.cs:第33行"
我在c#中有一个switch case语句,这里我作为私有常量的所有情况,这里有任何不好的编程实践,或者我需要在这里使用枚举和case case中的枚举器.我在这里展示了三个常量,我有十个常数和十个案例块
private const String FEASIBLESIZE = "Total FEASIBLESIZE";
private const String AVAILABLESIZE = "Total AVAILABLESIZE";
private const String EXCESSSIZE = "Total EXCESSSIZE";
.
.
switch (value.ToString())
{
case FEASIBLESIZE:
Level.Add(TEAMSIZE, test.ToString());
break;
case AVAILABLESIZE:
Level.Add(BROADSIZE, test.ToString());
break;
case EXCESSSIZE:
Level.Add(NARROWSIZE, test.ToString());
break;
.
.
.
Run Code Online (Sandbox Code Playgroud) 默认情况下,哪个.net框架将全新安装2008 R2?frameowkr 2.0或3.5或没有.如果我需要手动启用3.5意味着默认情况下已经安装了所有内容,我需要启用它还是需要安装?
我有一个函数,我把断点,并且可以看到它在除了UI线程之外的不同线程中我的意思是它是工作线程.i检查了线程窗口,当我检查线程创建和启动的地方时,我找不到.即使我也检查了callstack.当我钻我时,我只能看到那些东西开始
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) + 0x6c bytes
Run Code Online (Sandbox Code Playgroud)
最后以
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) + 0x74 bytes
Run Code Online (Sandbox Code Playgroud)
我们有没有任何机制来找到thread的起始位置.我的目标是改变工作线程的线程的aprtmentmodel