小编Fre*_*kyB的帖子

如何在ContextMenuStrip中对齐分隔符

这是我的ContextMenuStrip代码:

        ContextMenuStrip _menuStrip = new ContextMenuStrip();
        Image image = new Bitmap("icon_main.ico");
        _menuStrip.Items.Add("First item", image);

        ToolStripSeparator stripSeparator1 = new ToolStripSeparator();
        stripSeparator1.Alignment = ToolStripItemAlignment.Right;//right alignment
        _menuStrip.Items.Add(stripSeparator1);

        _menuStrip.Items.Add("Second item", image);

        ToolStripSeparator stripSeparator = new ToolStripSeparator();
        stripSeparator.Alignment = ToolStripItemAlignment.Left;//left alignment
        _menuStrip.Items.Add(stripSeparator);

        _menuStrip.Items.Add("Exit", image, OnClickExit);            
        _mainIcon.ContextMenuStrip = _menuStrip;
Run Code Online (Sandbox Code Playgroud)

奇怪的是分隔符没有对齐 - 我在ContextMenuStrip的边缘和分隔符之间有一点空间,即使我尝试对齐分隔符(我已经尝试了两个 - 左右对齐):

在此输入图像描述

这不是一个很大的图形失败,但我问自己这是如何完美地对齐的:

在此输入图像描述

任何想法我该怎么办?

c# winforms

5
推荐指数
1
解决办法
1949
查看次数

将对象数组作为隐藏字段值传递给MVC控制器

我正在使用VS2015,MVC5。我的提交表格:

        @using (Html.BeginForm("Test", "Home", FormMethod.Post))
    {
        <input name="celo" type="hidden" value="994" />
        <input name="pispis" type="hidden" value="Došel je prošel pisani Vuzem!" />
        <input name="userji" type="hidden" 
            value="[{'ID':1,'Name':'John','TotalPayed':0,'TotalDebt':0},
                {'ID':2,'Name':'George','TotalPayed':0,'TotalDebt':0},
                {'ID':3,'Name':'Simon','TotalPayed':0,'TotalDebt':0},
                {'ID':4,'Name':'Antonio','TotalPayed':0,'TotalDebt':0}]" />
        <input type="submit" value="Submit test"/>
    }
Run Code Online (Sandbox Code Playgroud)

控制器:

    public void Test(int celo, string pispis, List<User> userji)
    {

    }
Run Code Online (Sandbox Code Playgroud)

班级用户:

    public class User
{
    public int ID { get; set; }
    public string Name { get; set; }
    public int TotalPayed { get; set; }
    public int TotalDebt { get; set; }         
}
Run Code Online (Sandbox Code Playgroud)

值“ celo”和“ …

arrays asp.net-mvc

5
推荐指数
2
解决办法
9105
查看次数

Owin获取查询字符串参数

我试图从Owin请求获取查询字符串参数.虽然此参数位于查询字符串中,但参数"test"的获取操作仍为空.如何从OWIN主机读取请求参数?

呼叫:

localhost:5000/?test=firsttest
Run Code Online (Sandbox Code Playgroud)

码:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseHandlerAsync((req, res) =>
        {
            string paramTest = req.Get<string>("test");                             
            return res.WriteAsync(paramTest);
        });
    }
Run Code Online (Sandbox Code Playgroud)

.net owin katana

5
推荐指数
1
解决办法
4184
查看次数

ListItemCollection - 使用LINQ从值获取文本

我有ListItemCollection.每个元素都是类型ListItem.我想只返回带有值的项目的文本.

现在,我正在使用此功能:

public string GetTextFromPaymentWayCollection(string value)
{
  ListItemCollection listPaymentWays = DB.GetList();

  foreach (ListItem item in listPaymentWays)
  {
    if (item.Value == value)
    {
      return item.Text;
    }
  }
  return null;
}
Run Code Online (Sandbox Code Playgroud)

有没有办法用LINQ做这个,而不是使用这个功能?

c# linq

5
推荐指数
2
解决办法
3778
查看次数

从日期开始获取一年中的周数

我正在寻找一个查询,它将返回给定日期的周数.

我已经尝试过的是:

select datepart(wk, '2017-02-01')
Run Code Online (Sandbox Code Playgroud)

但这会返回5而不是6.(2月1日是一年的第6周).

(周数用红色)

在此输入图像描述

t-sql sql-server

5
推荐指数
3
解决办法
3万
查看次数

Sql server中的FLWOR计数命中数

我正在使用SQL Server 2008 R2.我的问题是我想要计算使用FLWOR从XQuery查询收到的点击次数.对于每次点击,我想要一个连续的数字,如:0,1,2,3,4 ......

我的查询:

select @xml.query('for $s at $count in /Root/Persons/Person
return <Person ID="{$count}">{$s}</Person>')
Run Code Online (Sandbox Code Playgroud)

这里唯一的问题是SQL Server不支持这个问题,我收到一个错误:

Msg 9335, Level 16, State 1, Line 16
XQuery [query()]: The XQuery syntax 'at' is not supported.
Run Code Online (Sandbox Code Playgroud)

我也尝试过let关键字并定义新变量,但我不知道如何在每次迭代时增加该变量的值?

感谢所有答案,弗伦基

xquery sql-server-2008-r2 xquery-sql flwor

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

Get nested XML output sql server

I have a problem with my xml output from sql server database. My table:

CREATE TABLE [dbo].[test_table](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [firstname] [nvarchar](255) NULL,
    [lastname] [nvarchar](255) NULL,
    [city] [nvarchar](255) NULL,
    [street] [nvarchar](255) NULL,
    [streetno] [int] NULL
)
Run Code Online (Sandbox Code Playgroud)

I want the output, where Address is nested inside each Person, like this:

<Root>
  <Person id="1">
    <firstname>Stefanie</firstname>
    <lastname>Buckley</lastname>
    <Address>
      <city>Oklahoma</city>
      <street> Cowley Road</street>
      <streetno>34</streetno>
    </Address>
  </Person>
  <Person id="2">
    <firstname>Sandy</firstname>
    <lastname>Mc Gee</lastname>
    <Address>
      <city>Montgomery</city>
      <street> Hague Parkway</street>
      <streetno>27</streetno>
    </Address>
  </Person>
</Root>
Run Code Online (Sandbox Code Playgroud)

I've tried …

xml sql sql-server

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

Javascript检查日期是否适合过去24小时

我在 javascript 中有一个以 format 给出的日期时间dd.MM.yyyy HH.mm

我需要检查的是这个日期是否适合过去 24 小时。

示例:如果现在的日期和时间是 06.04.2017 18:26 (dd.MM.yyyy HH.mm),则允许输入的最小日期是 05.04.2017 18:26。是否可以使用 javascript 进行此检查?

javascript jquery

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

Javascript内联函数调用

我有一个关于javascript内联函数调用的问题.

这个例子有效:

<button onclick="{alert($(this).text());}">Testing</button>
Run Code Online (Sandbox Code Playgroud)

虽然这不起作用:

<button onclick="function(){alert($(this).text());}">Testing</button>
Run Code Online (Sandbox Code Playgroud)

我的问题是 - 为什么第二种情况不起作用而第一种情况呢?

我使用jQuery-UI droppable来解决这个问题:

$( ".selector" ).droppable({
  drop: function( event, ui ) {}
});
Run Code Online (Sandbox Code Playgroud)

Droppable也使用这种语法(没有function()).这是为什么?

javascript jquery

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

根据第二个表中的值更新第一个表

我有两张桌子:

- @CAMERC
- @CAMERC_LOG
Run Code Online (Sandbox Code Playgroud)

我必须使用列@CAMERC.MERC_LPR中的值更新列@CAMERC_LOG.MERC_LPR.记录必须匹配MERC_KEY,但只能从一个记录中获取@CAMERC_LOG- 具有最高记录MERC_KEY_LOG,且@CAMERC_LOG.MERC_LPR不得为null或0.

我的问题是根据第二个表的结果更新一个表.我不知道如何正确地进行这样的更新?

表@CAMERC:

+----------+----------+
| MERC_KEY | MERC_LPR |
+----------+----------+
|        1 | 0.0000   |
|        2 | NULL     |
|        3 | 0.0000   |
|        4 | 0.0000   |
+----------+----------+
Run Code Online (Sandbox Code Playgroud)

表@CAMERC_LOG:

+----------+--------------+----------+
| MERC_KEY | MERC_KEY_LOG | MERC_LPR |
+----------+--------------+----------+
|        1 |            1 | 1.1000   |
|        1 |            2 | 2.3000   |
|        2 |            3 | 3.4000   | …
Run Code Online (Sandbox Code Playgroud)

t-sql sql-server sql-update

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