Note: While this sample is in VB.NET, I am language agnostic when it comes to a solution (i.e. I'll either code in back up in C# or convert a C# solution)
Setup:
1. Class with three properties, Firstname, Lastname, Age
2. Create 5 instances and add then to a List(of Class)
3. Set the List as the datasource for a DataGridView(setup as read only)
4. By default, the datagridview displays three columns and five rows
Question, is there a way to mark (via an attribute for example) the Age property in TestClass so it does not automatically bind/display in the grid?
Dim foo As New List(Of TestClass)
For i As Integer = 1 To 5
foo.Add(New TestClass("FirstTest " & i.ToString(), "LastTest " & i.ToString(), i))
Next
Me.DataGridView1.DataSource = foo
I thought I could do it by marking the age property as
<System.ComponentModel.Bindable(False)> _
Public Property Age() As Integer
Get
Return _age
End Get
Set(ByVal value As Integer)
_age = value
End Set
End Property
But that didn't work, it still gets bound (at least visually)
Supposedly it's fixed on Series consoles: https://support.forza.net/hc/e...e-Issues-in-Forza-Horizon-6
This game is so much better than FH5, and it's all because of the map. It's diverse, big, and so much to see and do. I've bought every single Forza Motorsport and Horizon game, and by far my least played is FH5 at 100 hours, followed by the latest Motorsport. They've finally made a good one with FH6
Question
+Biscuits Brown MVC
Note: While this sample is in VB.NET, I am language agnostic when it comes to a solution (i.e. I'll either code in back up in C# or convert a C# solution)
Setup:
1. Class with three properties, Firstname, Lastname, Age
2. Create 5 instances and add then to a List(of Class)
3. Set the List as the datasource for a DataGridView(setup as read only)
4. By default, the datagridview displays three columns and five rows
Question, is there a way to mark (via an attribute for example) the Age property in TestClass so it does not automatically bind/display in the grid?
Dim foo As New List(Of TestClass) For i As Integer = 1 To 5 foo.Add(New TestClass("FirstTest " & i.ToString(), "LastTest " & i.ToString(), i)) Next Me.DataGridView1.DataSource = fooI thought I could do it by marking the age property as
But that didn't work, it still gets bound (at least visually)
Link to comment
https://www.neowin.net/forum/topic/599628-binding-a-datagridview-to-an-ilist/Share on other sites
6 answers to this question
Recommended Posts