快捷键 | 说明 |
---|---|
Ctrl+- | 移动光标到上次位置或相反,比如定位一个函数,转到函数定义后想回到函数使用处,则用Ctrl+-,若又想回到函数定义处则可以按Shift+Ctrl+- |
Ctrl+] | 匹配选中的括号(大括号、小括号都行),在多层循环+判断语句时非常方便 |
Ctrl+Space | 代码补全 |
Ctrl+Tab | 在VS中切换打开的窗口,即切换各个文件 |
Ctrl+I | 递增搜索,与Ctrl+F不同的是搜索期间不显示搜索对话框,且Ctrl+F搜索下一个直接按Enter即可,而Ctrl+I搜索下一个按Ctrl+I或F3,Esc退出,连续按两次Ctrl+I重复上次搜索 |
Ctrl+Shift+F | 旧式的文件搜索对话框(与记事本中的搜索替换框差不多,可以替换) |
Ctrl+F3 | 为当前选中的部分进行搜索(不需要再输入要搜索的内容) |
Shift+Alt+Enter | 最大化代码编写区域(代码全屏模式),即去掉所有其它辅助窗口 只留下代码编写窗口,再按一次返回到原来界面 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConsoleWriterEventArgs : EventArgs | |
{ | |
public string Value { get; private set; } | |
public ConsoleWriterEventArgs(string value) | |
{ | |
Value = value; | |
} | |
} | |
public class ConsoleWriter : TextWriter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
花不啰嗦,直接看代码,数据绑定到DataTable上,如果有多个控件绑定到一个DataTable上,你又不需要控件之间联动, | |
请添加类似“ddList.BindingContext = new BindingContext();”的代码。 | |
我看到国内很多人的帖子都是用的DataTable的Copy方法,在某些情况下能满足要求,如果DataTable数据是要变动的Copy | |
大法就GameOver了,还是多用内建的方法,很多功能微软都为我们考虑好了, 是我们自己学艺不精不甚了解罢了。 | |
========================================================================================================== | |
RadDropDownList ddList = new RadDropDownList(); | |
...............(其它属性设置省略) | |
ddList.BindingContext = new BindingContext(); | |
ddList.DataSource = FilesDataTable; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<T> FindControlByType<T>(this Control mainControl, bool getAllChild = false) where T : Control | |
{ | |
List<T> lt = new List<T>(); | |
for (int i = 0; i < mainControl.Controls.Count; i++) | |
{ | |
if (mainControl.Controls[i] is T) lt.Add((T)mainControl.Controls[i]); | |
if (getAllChild) lt.AddRange(FindControlByType<T>(mainControl.Controls[i], getAllChild)); | |
} | |
return lt; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double ExtractDouble(this string str) | |
{ | |
Regex Reg = new Regex(@"[-+]?[0-9]*\.?[0-9]+"); | |
Match m = Reg.Match(str); | |
if (m.Success) | |
return Convert.ToDouble(m.Value); | |
else | |
return 0.0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void CopyDirectory(String sourcePath, String destinationPath) | |
{ | |
DirectoryInfo info = new DirectoryInfo(sourcePath); | |
Directory.CreateDirectory(destinationPath); | |
foreach (FileSystemInfo fsi in info.GetFileSystemInfos()) | |
{ | |
String destName = Path.Combine(destinationPath, fsi.Name); | |
if (fsi is System.IO.FileInfo) //如果是文件,复制文件 | |
File.Copy(fsi.FullName, destName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsDotNet35Installed() | |
{ | |
bool ret = false; | |
RegistryKey rk = OpenSoftwareKey(@"\Microsoft\NET Framework Setup\NDP\v3.5"); | |
if (rk != null) | |
{ | |
ret = true; | |
rk.Close(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Win32; | |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Security.Principal; | |
using System.Text; | |
using System.Threading.Tasks; |