一、windows应用程序最小化后,在状态条上如果有程序做某些操作,为了通知客户,如保让他闪动?
[System.Runtime.InteropServices.DllImport("user32.dll") ]
static extern int FlashWindow (int hwnd, int bInvert);
private void button1_Click(object sender, System.EventArgs e)
{
FlashWindow(this.Handle.ToInt32(),1);
}
如果你要闪动多次可以放在timer中执行
FlashWindow(this.Handle.ToInt32(),0);//停止闪烁
二、WinFrom中怎么统计DataGrid中选中的行数
for(i=0;i<ds.Tables[0].Rows.Count;i++)
{
if(datagrid.IsSelected(i)==true)
{
MessageBox.Show("1");
}
}
三、检测主机是否有Sqlserver
检测主机是否有Sqlserver
private bool GetSqlServerInfo(string strHostName)
{
bool bolConnectionInfo = false;
SQLDMO.Application sap = new SQLDMO.ApplicationClass();
SQLDMO.NameList servers = sap.ListAvailableSQLServers();
string _strHostName = string.Empty;
if (strHostName.ToUpper() == Dns.GetHostName().ToUpper())
{
_strHostName = "(local)";
}
else
{
_strHostName = strHostName;
}
for (int i = 0; i < servers.Count; i++)
{
object svr = servers.Item(i + 1);
if (string.Equals(_strHostName, svr.ToString()))
{
bolConnectionInfo = true;
break;
}
}
return bolConnectionInfo;
}
四、判断输入的是否是数字
// 名称:IsNumeric
// 功能:判断输入的是否是数字
// 参数:string oText:源文本
// 返回值: bool true:是 false:否
private static bool IsNumeric(string oText)
{
try
{
int var1 = Convert.ToInt32(oText);
return true;
}
catch
{
return false;
}
}