小编Abd*_*Haj的帖子

MouseDown和Click冲突

我在form_MouseDown事件上有一个Drag()方法.我在表单上也有一个点击事件.问题是,如果我单击表单,MouseDown事件将被触发,它永远不会有机会触发click事件.

解决这个问题的最佳方法是什么?如果表单实际被拖动,我在考虑计算像素,但必须有更好的方法.有什么建议?

c# winforms mousedown

8
推荐指数
2
解决办法
1万
查看次数

<asp:UpdatePanel>在表<tr>中不起作用?

<asp:UpdatePanel..><table>.. <tr> </tr>结构中工作时遇到问题,我不知道为什么.当UpdatePanel被注释掉时,一切正常,但是当我取消注释UpdatePanel时,<tr> </tr>标记的内容甚至都没有显示在Visual Studio 2010中.当我运行网页但UpdatePanel不显示时,会显示此内容工作.我这个项目中没有其他网页有这个问题但是,我再次使用<div>s代替<table> s.另一件事.该在我的MasterPage中.这是我的脚本:

<asp:UpdatePanel ID="W9UpdatePanel" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <tr>
          <td colspan="6">
            <div class="branchSetupSectionTitle">W-9 Information:</div>
          </td>
        </tr> 
        <tr>
           <td colspan="2">
             <asp:Button ID="btnDownloadW9Pdf" runat="server" 
             Text="Download W-9"  onclick="btnDownloadW9Pdf_Click" AutoPostBack="True" /> 
             <%--<asp:RegularExpressionValidator ID="RegularExpressionValidator24" 
              runat="server" ControlToValidate="txtFirstPaymentAmount" Display="Dynamic" 
              ErrorMessage="The dollar amount you entered is in the wrong format." 
              ForeColor="Red" ValidationExpression="^\d+(\.\d\d)?$">*</asp:RegularExpressionValidator>--%>
              <asp:CheckBox ID="chkW9FormSubmitted" runat="server" AutoPostBack="True" 
              oncheckedchanged="chkW9FormSubmitted_CheckedChanged" 
              Text=" I have submitted this W-9 Form" />
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
         </tr> 
    </ContentTemplate>
</asp:UpdatePanel> …
Run Code Online (Sandbox Code Playgroud)

c# asp.net ajax

6
推荐指数
1
解决办法
8988
查看次数

使用NodaTime将无效(跳过)日期时间值转换为UTC

我想要完成的是将DateTime(从假设在EST/EDT中的字符串解析)转换为UTC.我正在使用NodaTime,因为我需要使用Olson时区.

使用NodaTime的ZoneLocalMappingResolver将无效(跳过)DateTime转换为UTC不会转换输入的分钟和秒部分,因为我已将CustomResolver配置为返回间隙后的间隔开始.NodaTime似乎没有等效的TimeZoneInfo.IsInvalidTime.

如何使用NodaTime将跳过的日期时间值转换为UTC并匹配下面的Utils类中的GetUtc()方法的结果?(Utils.GetUtc方法使用System.TimeZoneInfo而不是NodaTime)

这是测试用例:

[TestMethod]
public void Test_Invalid_Date()
{
    var ts = new DateTime(2013, 3, 10, 2, 15, 45);

    // Convert to UTC using System.TimeZoneInfo
    var utc = Utils.GetUtc(ts).ToString(Utils.Format);

    // Convert to UTC using NodaTime (Tzdb/Olson dataabase)
    var utcNodaTime = Utils.GetUtcTz(ts).ToString(Utils.Format);

    Assert.AreEqual(utc, utcNodaTime);
}
Run Code Online (Sandbox Code Playgroud)

这就是我得到的:

Assert.AreEqual失败.预计:<2013-03-10 07:15:45.000000>.实际:<2013-03-10 07:00:00.000000>.

这是Utils类(也在github上):

using System;

using NodaTime;
using NodaTime.TimeZones;

/// <summary>
/// Functions to Convert To and From UTC
/// </summary>
public class Utils
{
    /// <summary>
    /// The date …
Run Code Online (Sandbox Code Playgroud)

c# timezone datetime dst nodatime

6
推荐指数
1
解决办法
1095
查看次数

如何将UTF-8阿拉伯字母转换为CodePage 1001?

我有一个支持CodePage 1001阿拉伯语的Star Micronics TSP,如何使用C#将UTF-8转换为该特定代码页?

更新:我发现CodePage 864与打印机兼容,我尝试发送十六进制值,我得到了正确的字符,

myPrinter.PrintNormal(PrinterStation.Receipt, "\xFE8D");
Run Code Online (Sandbox Code Playgroud)

我尝试以下将字符串转换为codePage 864:

Encoding enc = Encoding.GetEncoding(864);
byte[] arr = enc.GetBytes("??????");
Run Code Online (Sandbox Code Playgroud)

我在编码之后得到的字节arr值值{63,63,63,63,63,63}是错误的,甚至字节数也是错误的,因为它是一个双字节字符.

.net c# encoding character-encoding codepages

4
推荐指数
1
解决办法
4244
查看次数

如何屏蔽用户?

我想创建一个阻止用户而不是整个网络(调制解调器)的 php 脚本。我知道我可以从调制解调器获取 IP,但是我的服务器如何区分调制解调器背后的用户?有可能的解决方案吗?

php ip networking

4
推荐指数
2
解决办法
1150
查看次数

查询即将到来的生日

我想询问我的客户,他们的生日还未到来.

我已经尝试过这个查询,当然 - 它已经失败了:

Addresses.Where(adr => adr.DateOfBirth != null && adr.DateOfBirth.Value >
DateTime.Now).Take(15).ToList();
Run Code Online (Sandbox Code Playgroud)

当然这不能正常工作(如果你将来出生的话),我想知道如何在Nullable<DateTime>没有一年的情况下查询我的情况?

c# linq entity-framework-5

4
推荐指数
1
解决办法
2131
查看次数

用逗号分隔的连接字典键

我正在寻找一种更好的方法来连接字典键,这就是我现在正在做的事情:

Dictionary<int, string> myList = new Dictionary<int, string>();

myList.Add(1, "value");
myList.Add(2, "value");
myList.Add(3, "value");
myList.Add(4, "value");

string choices = "";

foreach (int key in myList.Keys)
{
    choices += key + " ";
}

choices = "(" + choices.Trim().Replace(" ", ",") + ")"; // (1,2,3,4)
Run Code Online (Sandbox Code Playgroud)

我确定有更好的方法,LINQ可能吗?

c# string dictionary concatenation comma

3
推荐指数
1
解决办法
8191
查看次数

透明标签控件显示为白色

无论如何,我对标签控件有点困难.当我将新的选项卡控件拖到窗体上时,它显示为白色,而不是我期待的灰色(系统颜色).

当我查看属性时,其颜色设置为Web透明.好的,那么它应该是透明的(它不会让它后面的任何东西显示出来).手动将选项卡控件背面颜色设置回系统灰色类型,但顶部的选项卡仍显示为白色.我假设我也能以某种方式改变它们的颜色,但是我很快就进入了从默认值改变这么多值的领域,我显然缺少某种类型的领域.我尽可能搜索"透明标签控件绘制白色"的每个变量,虽然我发现与Windows配置文件有关,但这似乎主要限于使用您在访问中访问的vb访问2003.

我正在寻找任何解释:

  • 我需要做些什么来正确使用选项卡控件的透明度
  • 我错误地理解了标签控件中透明度的目的
  • 如何轻松更改选项卡控件的相应部分的所有颜色以使其不透明.

我正在查看MCTS的Windows窗体,所以请不要给出"你应该使用X代替"类型的答案.

c# winforms

2
推荐指数
1
解决办法
4589
查看次数