小编Ola*_*röm的帖子

处理具有许多子控件的用户控件的双击事件

我有一个由许多子控件组成的用户控件,我需要处理用户控件的双击事件.所以我添加了事件处理程序,但它从未被触发过.

我发现最快的解决方案是迭代子控件并订阅他们的双击事件.这真的是正确的方法吗?还有更好的方法吗?谢谢.

.net c# events user-controls winforms

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

C# 数据绑定 ComboBox 更改其他控件中的数据

我再次遇到一个非常复杂的问题,所以我会尽力解释:

我有一个 C# Windows 窗体 (.NET 4) 程序。我的 Windows 窗体包含一个大的空白面板。
在这个程序中,我有一个带有设计器的 Windows 窗体 UserControl 类。用户控件是一个带有两个组合框和一个文本框的框(称之为菜单选项)。

用户控件上的每个组合框都使用以下方式绑定到不同的数据源:

comboBoxSelection1.DataSource = SelectionList1;
comboBoxSelection2.DataSource = SelectionList2;
Run Code Online (Sandbox Code Playgroud)

当用户使用组合框选择一个项目时,文本框会显示他们的选择。
例如,选择 1:牛排,选择 2:薯条。

该程序的全部要点是允许用户创建多个用户控件(菜单选项),每个控件具有不同的选择,从而产生一个选择列表(成为一个订单)。

到目前为止和我在一起吗?
在我开始使用 ComboBox 的 DataSource 之前,这工作得非常好,如下所示:

object[] comboBoxList1 = new object[SelectionList1.Count];
int i = 0;
foreach (Selection s in SelectionList1)
{
    string description = s.Description;
    comboBoxList1[i] = description;
    i++;
}
comboBoxSelection1.Items.AddRange(comboBoxList1);
Run Code Online (Sandbox Code Playgroud)

但是,我需要使用数据源来按 id 区分项目(某些显示的名称是相同的 - 我无法更改它)。

我现在使用以下内容:

comboBoxSelection1.DataSource = SelectionList1;
comboBoxSelection1.ValueMember = "Code";
comboBoxSelection1.DisplayMember = "Name";
Run Code Online (Sandbox Code Playgroud)

问题是,每当我更改其中一个用户控件上的comboBoxSelection1 时,面板上每个用户控件上的comboBoxSelection1 值都会更改为我当前的选择。如果我更改任何组合框选择 2 中的值,则组合框选择 2 也会发生同样的情况,所有组合框选择 …

.net c# combobox datasource winforms

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

Xamarin.Forms 中的计时器

我想构建自己的音频播放器(因为没有可用的插件)。我使用了一个滑块来显示玩家的进度。我可以允许用户在移动滑块时转到特定位置,但我无法将其与正在播放的录音同步。

形式

int i = 1;
Button btnPlay = new Button
{
    Text = "Play/Pause",
    Command = new Command(() =>
    {
        DependencyService.Get<IAudio>().PlayMp3File();
        TimeSpan tmspan = new TimeSpan(00, 00, 00);
        label.Text = String.Format("{0:hh\\:mm\\:ss}", tmspan.Add(TimeSpan.FromMilliseconds(i)));
        i++;
        return true;
    })
};
Button btnStop = new Button { Text = "Stop" };
TimeSpan timeSpan = DependencyService.Get<IAudio>().GetInfo();
Label lblDuration = new Label { Text = String.Format("{0:hh\\:mm\\:ss}", timeSpan) };

var slider = new Slider {
    Minimum = 0,
    Maximum = timeSpan.TotalHours,
};
var label = new …
Run Code Online (Sandbox Code Playgroud)

c# timer xamarin xamarin.forms

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

在 Visual Studio Code 中注释 Python 代码

当我尝试使用组合键+ +注释代码块时,我的 Visual Studio Code 注释 Python 代码时'''使用的是而不是使用。#CtrlShifta

我使用的是 Ubuntu 16.04。

python comments visual-studio-code

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

Xamarin.Forms 中的 Device.StartTimer 与 System.Threading.Timer

使用Device.StartTimervs的优点或缺点是System.Threading.Timer什么?

两者都在后台线程上触发,两者都是跨平台和 netstandard2 兼容的。System.Threading.Timer具有非 Xamarin 特定的奖励积分。

我应该使用什么以及何时使用?

  • Device.StartTimer 使用本机 API。
  • 根据github.com/monoSystem.Threading.Timer似乎所有计时器都使用专用线程。我是对的,还是 Xamarin 使用其他实现?

.net c# timer xamarin xamarin.forms

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

com.fasterxml.jackson.databind.exc.MismatchedInputException:无法反序列化实例?

我已尝试一切方法来读取以下 JSON 字符串,但仍然收到以下错误。
我的 JSON 字符串是有效的,我认为问题在于子元素的映射存在问题。

这是我的 JSON 字符串:

[
    {
        "denotations": [
            {
                "id": [
                    "CUI-less"
                ],
                "obj": "disease",
                "span": {
                    "begin": 31,
                    "end": 41
                }
            }
        ],
        "elapsed_time": {
            "ner": 2.759,
            "normalization": 0.002,
            "tmtool": 0.148,
            "total": 2.91
        },
        "logits": {
            "disease": [
                [
                    {
                        "end": 41,
                        "id": "CUI-less",
                        "start": 31
                    },
                    0.999957799911499
                ]
            ],
            "drug": [],
            "gene": [],
            "species": []
        },
        "project": "BERN",
        "sourcedb": "PubMed",
        "sourceid": "2832773",
        "text": "Absence of humoral immunity to poliovirus in vaccinated individuals.",
        "timestamp": …
Run Code Online (Sandbox Code Playgroud)

java arrays json list jackson

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

如何跳转到 Java 属性文件中的某个部分?

我有一个 Java 属性文件,其中有许多不同的属性用于不同的事情:

ui.datasource.st.name=MyTest
ui.datasource.st.port=111
ui.datasource.st.ip=1.1.1.1
ui.outputtype.snapshot=Snapshot
ui.outputtype.spreadsheet=Spreadsheet - xls
Run Code Online (Sandbox Code Playgroud)

该文件比这个大得多。

我想跳转到ui.outputtype部分,而不循环遍历文件并检查键值。

有没有办法做到这一点?

java properties sections

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

Android 中两行四个按钮填满整个屏幕

我想用四个具有相同宽度和高度的按钮填充整个屏幕,所以我认为网格布局是一个好主意:

<GridLayout
    android:id="@+id/grid"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="2"
    android:rowCount="2"
    >

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_columnWeight="1"
        android:layout_rowWeight="0"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_columnWeight="1"
        android:layout_rowWeight="0"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_rowWeight="1"
        android:layout_columnWeight="1"
        />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_rowWeight="1"
        android:layout_columnWeight="1"
        />

</GridLayout>
Run Code Online (Sandbox Code Playgroud)

不幸的是我的结果看起来像这样:

网格布局结果

我不明白为什么第二排的高度这么大?
我认为网格布局中的每个单元格都有相同的宽度和高度!

height android width android-layout android-gridlayout

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

如何在 Xamarin 中添加计时器?

所以我需要有一个计时器从 60 秒开始倒计时。我是 Xamarin 的新手,不知道它接受什么。它将在Android中使用。

关于如何开始的任何建议?

你能用System.Timers.Timer吗?

c# android timer xamarin

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

如何在C#控制台中检测“Enter”?

我对 C# 还很陌生,如果你能帮助我解决这个问题,我会很高兴。

我正在尝试检测何时Enter按下该键。

Console.Write("**Press Enter**" "to do this" or "**Press Esc**" "to do that");
Run Code Online (Sandbox Code Playgroud)

我们通常在此之后使用 readline,但前提是用户要写一些东西。

这次我想检测用户是否按下了EnterEsc

c# console keyboard-events

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