我有一个标签控件,需要删除所选标签周围的虚线焦点矩形.
我已将TabControl的TabStop属性设置为false.但是,如果单击选项卡并Tab按键,则会在tabname周围显示虚线矩形.
我试过创建自己的TabControl并试过这个
class MyTabControl : TabControl
{
public MyTabControl()
{
TabStop = false;
DrawMode = TabDrawMode.OwnerDrawFixed;
DrawItem += new DrawItemEventHandler(DoMoreTabControl_DrawItem);
Invalidate();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,仍然会出现虚线矩形.
我也尝试重写该MyTabControl.OnPaint()方法,但它没有帮助.
有没有办法实现这个目标?
所以,我有一个方法,它包含对服务器的异步调用.该代码是从第三方工具调用的,它有时会从不同的线程连续多次调用相同的方法,所以我不能影响它.
我想要确定的是我的方法被调用一次,然后,应该忽略另一个调用.
起初,我试图用bool isBusy来锁定(locker),但是我不满意,因为异步请求仍然从第二个线程被多次调用,这很快就能看到isBusy = true;
然后,我尝试了Monitor
object obj = new object();
Monitor.TryEnter(obj);
try
{
var res = await _dataService.RequestServerAsync(SelectedIndex, e.StartIndex, e.Count);
****
}
finally
{
Monitor.Exit(obj);
}
Run Code Online (Sandbox Code Playgroud)
然而,在Exit(),我得到例外:
"System.Threading.SynchronizationLockException"类型的第一次机会异常
有没有其他方法可以保证只执行一次代码?
我使用受信任或SQL登录在下面的代码中得到相同的错误:
VS2010,控制台应用程序.NET4,Win XP.SQL2005完整版.
转移炸弹.TransferData
错误:errorCode = -1073548784 description =执行查询""失败,并显示以下错误:"由于以下错误,检索具有CLSID {19E353EF-DAF4-45D8-9A04-FB7F7798DCA7}的组件的COM类工厂失败:80040154" .可能的故障原因:查询问题,"ResultSet"属性设置不正确,参数设置不正确或连接未正确建立.
这感觉就像安全.任何想法都会很棒!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Collections.Specialized;
using System.IO;
using System.Configuration;
namespace GenerateScripts
{
class Program
{
static void Main(string[] args)
{
ServerConnection sourceConnection = new ServerConnection("localhost");
Server sourceServer = new Server(sourceConnection);
//sourceServer.ConnectionContext.LoginSecure = false;
//sourceServer.ConnectionContext.Login = "3tier";
//sourceServer.ConnectionContext.Password = "3tier";
Database sourceDatabase = sourceServer.Databases["3tier"];
// destination
ServerConnection destinationConnection = new ServerConnection("localhost");
Server destinationServer = new Server(destinationConnection);
//destinationServer.ConnectionContext.LoginSecure = false;
//destinationServer.ConnectionContext.Login …Run Code Online (Sandbox Code Playgroud) 我在从Excel工作表中读取DateColumns时遇到问题.
有时人们会使用不同的日期格式,这会带来问题.假设我07/26/2010从Excel列中得到的结果26-Jul-2010是因为用户已更改其日期格式.
我用它Microsoft.Jet.OLEDB来读取xls表格DataTable.
我可以以某种方式强制OleDb读取器,无论在XLS上设置DateFormat,将所有日期转换为MM/DD/YYYY格式?
我用这段代码来读取Excel文件:
string strConn;
strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + uploadedFileInfo.FullName + ";" +
@"Extended Properties=""Excel 8.0;HDR=NO;""";
using (OleDbConnection connToExcel = new OleDbConnection(strConn))
{
//You must use the $ after the object you reference in the spreadsheet
connToExcel.Open();
string firstSheetName = ExcelUploadedFileReaderBuilder
.GetFirstExcelSheetName(connToExcel);
OleDbDataAdapter myCommand
= new OleDbDataAdapter(String.Format("SELECT * FROM [{0}]", firstSheetName), connToExcel);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "uploadedExcelTable");
DataTable dtUploadedExcel = myDataSet.Tables["uploadedExcelTable"];
lineCount = GetLineNumberWhereNULLRowOccured(dtUploadedExcel) + …Run Code Online (Sandbox Code Playgroud) 我想知道存储哪种文件
C:\ Program Files(x86)\ Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 \
这些文件是否适用于WPF/Silverlight?
哪个安装程序将文件安装在该文件夹中?
我想知道这一点,因为我们开发了一个带有自定义WPF控件的winforms应用程序.当我们在裸系统上部署应用程序时,应用程序在使用这些控件时崩溃...
我工作的地方,用户必须输入某种字符串的程序,并计划将其存储在一个列表或数组,然后计算项目是重复了多少遍.
然后以重复次数的降序显示最重复的三个项目(第一个有10个重复,第二个有9个,第三个有8个)
听起来很简单.由于我不知道有多少人会输入一个字符串,我使用了一个列表,然后按照这个例子:
foreach (string value in list.Distinct())
{
System.Diagnostics.Debug.WriteLine("\"{0}\" occurs {1} time(s).", value, list.Count(v => v == value));
}
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,.Distinct()不会出现在我的列表名称之后.我做错什么了吗?这与我的C#有关,这不是C#3.0吗?该示例从未提及有关添加其他引用等的任何内容.
有没有其他方法可以做到这一点?
我在C#中混淆了double [] []和double [,].
我的队友给我一个这样的功能:
public double[][] Do_Something(double[][] A)
{
.......
}
Run Code Online (Sandbox Code Playgroud)
我想使用这个功能:
double[,] data = survey.GetSurveyData(); //Get data
double[,] inrma = Do_Something(data);
Run Code Online (Sandbox Code Playgroud)
它导致错误:无效的参数.
我不想编辑我队友的代码.
有没有办法转换double[][]成double [,]?
谢谢!
Top Tier Object
SubTier Objects
SubSubTier Objects 1.1,1.2,1.3 : SubTierId = 2
SubSubTier Objects 2.1,2.2,1.3 : SubTierId = 3
SubTier Objects
SubSubTier Objects 3.1,3.2,3.3 : SubTierId = 1
SubSubTier Objects 4.1,4.2,4.3 : SubTierId = 2
Run Code Online (Sandbox Code Playgroud)
预期的最终结果是获得一个IEnumerable,其中包含1.2,2.3,3.1,4.2,它们代表每个子层的SubTierId.
SubSubTiers mySubSubTier = allTiers.Select(topTier =>
topTier.SubTiers.Where(sbTier => sbTier.Id == topTier.SubTierId));
Run Code Online (Sandbox Code Playgroud)
但是我得到的是这种返回类型.
IEnumerable<IEnumerable<SubSubTier>>
Run Code Online (Sandbox Code Playgroud)
是什么使我只是得到一个最好的办法IEnumerable的SubSubTier?
Z-Index使用DrawingContext.DrawXXX()方法时如何设置绘图对象?
有没有办法将消息的子字符串获取到 nlog 布局?就像是${${substring(0,200)}message}
<parameter name="@Summary" layout="${substring(0,200)}${message}"/>
Run Code Online (Sandbox Code Playgroud)
如果这能写出 message.substring(0, 200); 的等价物,那就太酷了。
<target type="Database" name="databaseLog"
ConnectionStringName="ApplicationConnectionString">
<commandText>
INSERT INTO [Log] ([Description] ,[Summary] ,[Level] )
VALUES (@Description, @Summary, @Level )
</commandText>
<parameter name="@Description" layout="${message}"/>
<parameter name="@Summary" layout="{{SUBSTRING-OF-MESSAGE-HERE}}"/>
<parameter name="@Level" layout="${level}"/>
</target>
Run Code Online (Sandbox Code Playgroud)