我有一个带有几个项目的ComboBox.我想把SelectedIndexComboBox放到0,所以当用户启动它时,第一个项目已经被选中(默认).
但是,执行this(combobox.SelectedIndex = 0;)会干扰我的事件combobox_SelectedIndexChanged(),当用户更改ComboBox的SelectedIndex时,会发生重新启动程序:
private void combobox_SelectedIndexChanged(object sender, EventArgs e)
{
Process.Start(Application.ExecutablePath);
this.Close();
}
Run Code Online (Sandbox Code Playgroud)
这将导致combobox_SelectedIndexChanged()循环无穷,combobox.SelectedIndex = 0;将触发它,这将再次触发另一个等等......
在没有这种循环的情况下,有没有办法让程序在用户更改SelectedIndex时做一些事情?
我的图标TaskDialog丢失了:

在任务栏中:

我的代码是这样的:
using Microsoft.WindowsAPICodePack;
using Microsoft.WindowsAPICodePack.Dialogs;
...
TaskDialog taskDialog = new TaskDialog();
taskDialog.Caption = "Error";
taskDialog.InstructionText = "Test error message.";
taskDialog.Text = "Icon seems to be missing.";
taskDialog.DetailsExpandedText = "Test";
taskDialog.DetailsCollapsedLabel = "Expand";
taskDialog.StandardButtons = TaskDialogStandardButtons.Ok;
taskDialog.Icon = TaskDialogStandardIcon.Error;
taskDialog.Show();
Run Code Online (Sandbox Code Playgroud)
我从这里使用1.1版.任何线索,为什么他们失踪以及如何启用它们?依赖关系设置如下:
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我有两个水平排列的TextView LinearLayout.因为它们只显示几个单词,所以第一个仅限于maxLines=1和ellipsize=marquee.
通常,它看起来像这样:
TextView1中的 文本TextView 2中的文本
但是,如果TextView 1太长,TextView 2将不再可见,因为第一个占用了所有空间:
TextView1文本文本文本文本中的文本...
现在,我只想对TextView 1进行椭圆化处理,以便TextView2始终完全可见.我已经尝试过设置layout_weight="1"第一个,但是在没有省略时会留下空间.
TextView1中的文本 ------------------- TextView 2中的文本
android ellipsis textview android-layout android-linearlayout
目前,当我从其位置执行滑动手势时,会打开一个微调器,允许我通过释放来选择一个项目。
我想禁用它,因为它会干扰 ScrollLayout 和 ViewPager 中的滚动。在任何情况下,旋转器都只能通过单击打开,而不是通过任何手势。
我想将第2列中的所有值写入列表:
List<string> list = new List<string>();
foreach (var item in dataGridView1.Rows)
{
list.Add(item.Cells[1].Value.ToString);
}
Run Code Online (Sandbox Code Playgroud)
但是,这会返回错误.
Toolbar当用户在的一个TabLayout标签(由提供ViewPager)中滚动时,我想让折叠折叠起来。
这是我想要的功能:
但是,我的布局不仅不滚动,而且还切断了底部的内容(确切地说,它切断了48dp -工具栏的高度):
我使用ViewPager将每个片段显示为选项卡。碎片由一个简单的ScrollView持有TextView。这是布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/ueber_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/ueber_tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabIndicatorColor="@android:color/white"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/ueber_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
每个片段具有以下布局:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/ueber_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="#000000"
android:linksClickable="false"
android:textColorLink="#000000"
android:fontFamily="serif"
android:padding="16dp"/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
ViewPager由ViewPagerAdapter设置:
ViewPager viewPager = (ViewPager) findViewById(R.id.ueber_viewpager);
ViewPagerAdapter adapter = new …Run Code Online (Sandbox Code Playgroud) android android-toolbar androiddesignsupport android-tablayout
所以我创建了一些这样的代码:
label1.Text = "Test";
label2.Text = "Test";
label3.Text = "Test";
Run Code Online (Sandbox Code Playgroud)
我的问题是,你能以某种方式同时将"文本"放到所有三个标签上吗?
像这样(当然不起作用)
label1.Text & label2.Text & label3.Text = "Test";
Run Code Online (Sandbox Code Playgroud) 我有一个列表字符串:
List<string> Entries = new List<string>();
Entries.Add("The quick brown fox jumps over the lazy dog");
Entries.Add("Lorem ipsum dolor sit amet");
Entires.Add("Consetetur sadipscing elitr");
Run Code Online (Sandbox Code Playgroud)
我可以搜索"fox"列表中的内容并"The quick brown fox jumps over the lazy dog"返回整行()吗?
我想知道哪种最有效的方法来获取DataGridView行中第一列的值。
目前,我正在使用以下代码:
List<string> SelectedRows = new List<string>();
foreach (DataGridViewRow r in dgv.SelectedRows)
{
SelectedRows.Add(r.Cells[0].Value.ToString());
}
int index = Convert.ToInt32(SelectedRows[0]);
Run Code Online (Sandbox Code Playgroud)
这很好用;但是,有没有更有效的选择呢?
所以我在一个目录中得到了一堆文件.
它们都是这样命名的:
所以我将所有这些项目放在一个目录中并将它们放入一个数组中:
string[] pictures = Directory.GetFiles(@"C:/Pictures", "*.jpg");
Run Code Online (Sandbox Code Playgroud)
我得到了一个包含3列的ListView,名称,日期和文件大小.
我想从文件名中获取所有这些信息,然后将它们放入listview.所以对于这三个文件,它看起来像这样:
名称--------------日期---------------------------文件大小
丹尼尔---- --------- 10.2013年9月-------- 26 KB
彼得-------------- 06.2012年5月----------------- 39 KB
Christiane -------- 08.2011年1月------------ 35 KB
所以我想到了在数组中拆分信息foreach然后使用另一个循环来编写ListView中的数据,但我不确切知道如何做到这一点.
任何帮助表示赞赏^^
干杯
(5/15)*1185应该给395.
decimal Test = (5 / 15) * 1185;
Run Code Online (Sandbox Code Playgroud)
然而,这会返回0.我做错了什么?