I have 2 questions concerning C#.
我有2个关于C#的问题。
1) I have a dropdown menu with several items in them. They are clickable, but when I click one, the older clicked one stays selected. Click another and the 2 original ones stay selected, and so on. I don't want this. What I want is that when I click one of the dropdownitems, that one is that selected one and the others are not.
1)我有一个下拉菜单,里面有几个项目。它们是可点击的,但当我点击一个时,较旧的点击一个保持选中状态。单击另一个,原始的2个保持选中状态,依此类推。我不想要这个。我想要的是,当我点击其中一个dropdownitems时,那个是选定的一个而其他的不是。
2) I have a listview items on a winform. I loaded some string elements into it from a file. Now what I want to do is to be able to edit those strings and even add strings, just by clicking on the rows in which the data goes.
2)我在winform上有一个listview项目。我从文件中加载了一些字符串元素。现在我想做的就是能够编辑这些字符串甚至添加字符串,只需单击数据所在的行即可。
I've checked google and MSDN for these problems, but nothing helps, so I turn here.
我已经检查了谷歌和MSDN的这些问题,但没有任何帮助,所以我转向这里。
2 个解决方案
#1
2) The ListView does not support that type of action. You can roll your own (pain in the @$$), or perhaps a DataGrid would be better suited to your purpose.
2)ListView不支持该类型的操作。你可以自己滚动(@ $$中的痛苦),或者DataGrid可能更适合你的目的。
EDIT:
This link may help
This one too
这个链接也可以帮助这个
#2
For #1 I'm a little confused. If the DropDownStyle isn't set to simple something strange is occuring. It's not much but maybe you could try recreating the control.
对于#1我有点困惑。如果DropDownStyle没有设置为简单,则会发生奇怪的事情。它并不多,但也许你可以尝试重新创建控件。
For #2 the easiest solution I can think of is to set a TextBox to be equal to the selected text value from your listview. After that write a little function to update the selected index of the listview with the edited text from the listview.
对于#2,我能想到的最简单的解决方案是将TextBox设置为等于列表视图中的选定文本值。之后,编写一个小函数,用listview中编辑的文本更新列表视图的选定索引。
Please comment if you have any more information about #1.
如果您有关于#1的更多信息,请发表评论。
#1
2) The ListView does not support that type of action. You can roll your own (pain in the @$$), or perhaps a DataGrid would be better suited to your purpose.
2)ListView不支持该类型的操作。你可以自己滚动(@ $$中的痛苦),或者DataGrid可能更适合你的目的。
EDIT:
This link may help
This one too
这个链接也可以帮助这个
#2
For #1 I'm a little confused. If the DropDownStyle isn't set to simple something strange is occuring. It's not much but maybe you could try recreating the control.
对于#1我有点困惑。如果DropDownStyle没有设置为简单,则会发生奇怪的事情。它并不多,但也许你可以尝试重新创建控件。
For #2 the easiest solution I can think of is to set a TextBox to be equal to the selected text value from your listview. After that write a little function to update the selected index of the listview with the edited text from the listview.
对于#2,我能想到的最简单的解决方案是将TextBox设置为等于列表视图中的选定文本值。之后,编写一个小函数,用listview中编辑的文本更新列表视图的选定索引。
Please comment if you have any more information about #1.
如果您有关于#1的更多信息,请发表评论。