C#中 - 添加按钮内部列表框按钮、列表

2023-09-03 03:59:16 作者:霸道是我的个性

我正在写一个C#应用程序(WinForm的)与用户添加一个列表框有内容。现在,我可以列表框下一个普通的按钮,删除项目,但我想有旁边的内容的按钮,因而是列表框的里面。

I'm writing an C# App (WinForm) with a ListBox having content added by the user. Now, I could have a ordinary button under the ListBox to remove items, but I would like to have the button right next to the content, thus being inside of the ListBox.

这样的:

在内容1 | X 在内容2 | X ... 内容5 | X

现在的问题是,我缺乏.NET经历让我对如何做到这一点有可能与所有的自动化控制事情没有任何线索。我GOOGLE了,但提出了任何有意义的结果。

The problem is that I lack experience in .NET so I have no clue on how this would be possible with all the automated controls going on. I've googled it, but came up with no meaningful results.

任何提示,线索或片段实现这一目标,欢迎! :)

Any hints, clues or snippets for achieving this are welcome! :)

推荐答案

因此​​,人们可以做一个自定义的控制,但我的应用程序它是不是真的值得的麻烦。

So one could make a custom control but for my app it isn't really worth the trouble.

我所做的就是创建一个DataGrid,使它像一个ListView,但有自己的耀斑。我这样做是因为DataGrid中已经内置了它的细胞buttoncontrol。

What I did was to create a DataGrid, made it resemble a ListView but with its own flare. I did this because the DataGrid already has a buttoncontrol built in to its cells.

是的,我知道,那种的fugly黑客,但它就像一个魅力! :)

Yes I know, kind of fugly "hack", but it works like a charm! :)

道具吉文Erlichmen谁领导我以为outsite我的列表框。见我做什么呢? ;)

Props to Shay Erlichmen who led me into thinking outsite my ListBox. See what I did there? ;)