小编Mec*_*eer的帖子

从 List(Of T) 中删除重复项

如何删除我的重复项List(Of String)?我假设它可以与 一起使用List(Of T).Distinct,但我的结果并非如此。我究竟做错了什么?或者我必须更改什么才能删除List(Of T).

我在万维网上读过一些关于散列的东西,但我认为这不是必要的。

这是我生成列表的代码(适用于 Autodesk Inventor)。

Private Function CountCylinders(ByVal oDef As AssemblyComponentDefinition) As Integer

    ' Lets list all cylinder segments found in the assembly
    ' we will need the document name to do this.
    ' the initial value is nothing, if, after counting
    ' this is still the case, there are no cylinders.
    Dim oList As New List(Of String)

    ' Loop through all of the occurences found in the assembly
    For …
Run Code Online (Sandbox Code Playgroud)

vb.net list duplicates

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

vb.net 类只读属性作为列表(T)

我正在寻找一个使用 a 的例子 read-only property as list(of T)

Public ReadOnly Property oList As List(Of String)
Get
    Return ...
End Get
Run Code Online (Sandbox Code Playgroud)

当我通常使用 list(of T) 时,我总是New在变量类型前面使用构造函数Public Property oList as New list(of T)

但是当我现在这样做时,我从 Visual Studio 收到一条错误消息。那么这是如何工作的呢?

我以前从未使用过只读属性..

vb.net properties class list readonly

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

当 ctrl+enter 按下时 Datagridview 多行文本框

我正在尝试向datagridview控件添加一些特定的行为(如果你可以这样说的话)。

我想multiplelines textbox在datagridview. 我在给出一个太长而无法放入 的字符串时实现了这一点textbox,它会自动放置在第二行。

所以步骤是在单元格中输入文本,而焦点在单元格上按 ctrl+enter 以便接下来输入的文本位于第二行。

dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
Run Code Online (Sandbox Code Playgroud)

但是我也可以通过按ctrl + enter key在这件事上强制第二行,我的互联网搜索空空如也。

我想它会在单元格内捕获按键事件,但我似乎找不到这个事件。

可能的事件

我试过这个事件,但只有Datagridview在选择了总数时才会发生。

Private Sub DataGridView1_CellContentClick(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress
     ' Some magic here.
End Sub
Run Code Online (Sandbox Code Playgroud)

vb.net datagridview multiline winforms

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

按对象属性对(对象)列表进行排序

我正在努力实现一些已经给出答案的事情。但它已经出现了c#,我对此一无所知,c#所以我正在寻找 vb.net 的替代品。

我打了一个class电话BomItem,它有几个属性,如数量、描述等。

我将它们添加BomItems到 a 中List(of BomItem),但现在我想根据属性对它们进行排序。如何根据属性对项目进行排序ItemNumber?

这是我找到的解决方案的链接c#。

我的班级代码

Public Class BomItem
    Public Property ItemNumber As String
    Public Property Description As String
    Public Property Quantity As Double
    Public Property Material As String
    Public Property Certificate As String
End Class
Run Code Online (Sandbox Code Playgroud)

我如何添加BomRow对象

    _NewBomList.Add(New BomItem() With {
                    .ItemNumber = oRow.ItemNumber,
                    .Description = oPropSet.Item("Description").Value,
                    .Quantity = oRow.TotalQuantity,
                    .Material = oPropSet.Item("Material").Value,
                    .Certificate = CustomPropertySet.Item("Cert.").Value})
Run Code Online (Sandbox Code Playgroud)

比较器 …

vb.net sorting properties list

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