Ячейка DataGridView с типом интерфейса не отображает значениеC#

Место общения программистов C#
Anonymous
Ячейка DataGridView с типом интерфейса не отображает значение

Сообщение Anonymous »


I Have a DataGridView that's working just fine displaying data as follows:

private DataGridView dgv; private List Items = new(); Items.Add(new() {ID = 1, Service = new() { Name = "Item 1"}, Quantity = 2}); dgv.DataSource = Items; // [...] Public Class Item { public int ID {get; set;} public Service Service {get; set;} public int Quantity {get; set;} } Public Class Service { public string Name {get; set;} Public overrides string To string => Name; } Everything was working just fine until I introduced

public interface IService { public string Name {get; set;} } And then changed:

public Service Service {get; set;} To:

public IService Service {get; set;} And then have the Service class implements the interface:

public class Service: IService... Everything works still except that the Service column in the DataGridView shows nothing, although when I hover over it with mouse I can see the value


Источник: https://stackoverflow.com/questions/779 ... ow-a-value

Вернуться в «C#»