如何:从列表中删除项目
我有以下代码片段...
companies.Remove(listView_Test.SelectedItem.ToString());
Run Code Online (Sandbox Code Playgroud)
有一个listView
包含(假设)3个没有名字的项目,只有一个Content
"A","B"和"C".现在,当我选择一个项目时listView
,我再次单击一个按钮,该按钮运行包含Remove()
/的方法RemoveAt()
.现在我想删除与所选项目List<string> myList
的行相同的行Content
.
编辑:Flow Flow OverFlow的解决方案
int index = companies.IndexOf(companyContent);
companies.RemoveAt(index);
Run Code Online (Sandbox Code Playgroud) 如何:对列表使用AddRange
List<string> list =
new List<string>().AddRange(File.ReadAllLines(path, Encoding.UTF8);
Run Code Online (Sandbox Code Playgroud)
它是一个全局声明的变量 - 我的错误是什么?
错误等于
不允许从字符串转换为void
那条线是什么意思?
^-...------ | wc ...
它是Bash脚本的一部分.
今天我开始上课.我创建了一些类来让我MainWindow.xmal.cs
更小一些.创建第一个类和调试后,我收到以下错误消息:
Eine nicht behandelte Ausnahme des Typs"System.StackOverflowException"ist in mscorlib.dll aufgetreten.
Eine nicht behandelte Ausnahme des Typs"System.StackOverflowException"ist in APPLICATION.exe aufgetreten.
class Sprachpaket_ENG_Template01
{
MainWindow MW = new MainWindow();
public void Template01()
{
MW.checkBox_1_Bcc.Content = "Bcc:";
MW.checkBox_1_Cc.Content = "Cc:";
}
Run Code Online (Sandbox Code Playgroud)
- >这会导致错误:MainWindow MW = new MainWindow();
如何:创建一个GridSplitter,自定义DockPanel(C#,WPF)的大小
这是我的GridSplitter
代码,但不幸的是它不起作用:我不允许改变我的大小grid
.我可以看到GridSplitter
,但我无法使用它.
<DockPanel DockPanel.Dock="Left" Name="dockPanel_1" Width="200">
<StackPanel />
<DockPanel />
</DockPanel>
<Grid>
<GridSplitter ShowsPreview="True" Width="5" HorizontalAlignment="Right" VerticalAlignment="Stretch" />
</Grid>
<DockPanel DockPanel.Dock="Right" Name="dockPanel_2">
<StackPanel />
<DockPanel />
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
PS:如果您知道如何保存更改的大小,以便在重新启动应用程序时将其大小调整为相同,只需添加到您的帖子中即可.
提前致谢.
我的申请有问题.我在App.xaml中选择了Loadscreen.xaml作为"StartupUri".Loadscreen.xaml.cs包含一个进度条,它运行到100% - 比它关闭并打开MainWindow.问题是,它在关闭Loadscreen后打开MainWindow两次.我的谬论是什么?
App.xaml中:
StartupUri="Loadscreen.xaml"
Startup="Application_Startup">
Run Code Online (Sandbox Code Playgroud)
Loadscreen.xaml.cs:
public void Timer_Tick(object sender, EventArgs e)
{
progressBar_Ladebalken.Value = i;
label_Titel.Content = i + "%";
Mouse.OverrideCursor = Cursors.Wait;
if (i < 100)
{
i += 1;
}
else
{
i = 0;
Mouse.OverrideCursor = null;
Timer.Stop();
Window W = new MainWindow();
W.Show();
this.Close();
}
Run Code Online (Sandbox Code Playgroud)
public void Application_Startup:
public void Application_Startup(object sender, StartupEventArgs e)
{
bool Absicherung;
Mutex Mutex = new Mutex(true, this.GetType().GUID.ToString(), out Absicherung);
if (Absicherung)
{
Window W = new Loadscreen();
W.Closed …
Run Code Online (Sandbox Code Playgroud) c# ×5
list ×2
string ×2
addrange ×1
bash ×1
dockpanel ×1
listview ×1
mainwindow ×1
selecteditem ×1
shell ×1
word-count ×1
wpf ×1
xaml ×1