1

I have the following class:

    class Channel
   {
    public int Number { get; private set; }

    public double HighestCoChannelSignal { get; private set; }
    public double HighestOverlappingSignal { get; private set; }

    public List<Network> NetsCoChannel { get; set; }
    public List<Network> NetsOverlapping { get; set; }
   }

I have a list of Channel objects. I want to bind it to a DataGridView and show: Number, HighestCoChannelSignal, HighestOverlappingSignal, NetsCoChannel.Count, NetsOverlapping.Count. And for example if the HighestCoChannelSignal is a special value set the cell value in DataGridView to something I want. How can I achieve this?

1 Answer 1

1

You can perform a LINQ query to get the data you want into instances of an anonymous type and bind the result to the grid, e.g.

var data = channels.Select(c => new {c.Number,
                                     c.HighestCoChannelSignal,
                                     c.HighestOverlappingSignal,
                                     NetsCoChannelCount = c.NetsCoChannel.Count,
                                     NetsOverlappingCount = c.NetsOverlapping.Count})
                   .ToArray();

You can add whatever code is appropriate to deal with that "special value". If you want a specific answer then you'll have to provide a specific description.

Sign up to request clarification or add additional context in comments.

2 Comments

It looks good, but I wonder what will be the performance in this solution, because I refresh the data on every 1 second.
Why are you wondering when you can simply test it and see? If the data is coming from a database then it would probably be quicker to get it in the form you want in the first place. If that's not an option, you're not really going to do any better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.