Hi All,

I was trying to show items in a datagridview and couldn't find a complete solution to this problem.
Why? I wanted to visualize to the user the diffrence if they opted for certain values. In mycase certain choises would show phonenumbers on intranet.

To show how I wil leave the control names default. To recreate the the project. Start a windows form application, place a datagridview, and 2 bindingsources on the form

To start we need some data to show and a list to choose from.
To make a simple example I chosen to make a person class containing an Id, Name and PositionId
If the Position is a staff position it should be blue others should remain the default style
But lets start with the colorScheme Interface so we can store the colorscheme we want to show for a certain positionitem in the datagrdview
It wil need back and forecolors but also colors for teh item whilst selected. To show the Displaymember we want to see I've also added the toString property that should shadow the toString of the object.

Code:
Public Interface IDatagridViewColorScheme

    Property ForeColor() As Color
    Property BackColor() As Color
    Property SelectionForeColor() As Color
    Property SelectionBackColor() As Color
    ReadOnly Property ToString() As String
End Interface
and a person Interface
Code:
Public Interface IPerson

    Property Id() As Integer
    Property Name() As String
    Property PositionId() As Integer

End Interface
We need a interface for the postions as well
I know we can do without interfaces but I won't, and the IDatagridViewColorScheme
will help making this code reusable.
Code:
Public Interface IPosition

    Inherits IDatagridViewColorScheme

    Property Id() As Integer
    Property PositionDesription() As String
    Property IsManaging() As Boolean

End Interface
Next step make the objects we need:
Code:
Public Class Person
    Implements IPerson

    Private _Id As Integer
    Private _Name As String
    Private _PositionId As Integer


    Public Property Id() As Integer Implements IPerson.Id
        Get
            Return _Id
        End Get
        Set(ByVal value As Integer)
            _Id = value
        End Set
    End Property

    Public Property Name() As String Implements IPerson.Name
        Get
            Return _Name
        End Get
        Set(ByVal value As String)
            _Name = value
        End Set
    End Property

    Public Property PositionId() As Integer Implements IPerson.PositionId
        Get
            Return _PositionId
        End Get
        Set(ByVal value As Integer)
            _PositionId = value
        End Set
    End Property
End Class

Public Class Position

    Implements IPosition

    Private _Id As Integer
    Private _PositionDesription As String
    Private _IsManaging As Boolean
    Private _ForeColor As Color
    Private _BackColor As Color
    Private _SelectionForeColor As Color
    Private _SelectionBackColor As Color

    Public Property BackColor() As System.Drawing.Color Implements IDatagridViewColorScheme.BackColor
        Get
            Return _BackColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _BackColor = value
        End Set
    End Property

    Public Property ForeColor() As System.Drawing.Color Implements IDatagridViewColorScheme.ForeColor
        Get
            Return _ForeColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _ForeColor = value
        End Set
    End Property

    Public Property SelectionBackColor() As System.Drawing.Color Implements IDatagridViewColorScheme.SelectionBackColor
        Get
            Return _SelectionBackColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _SelectionBackColor = value
        End Set
    End Property

    Public Property SelectionForeColor() As System.Drawing.Color Implements IDatagridViewColorScheme.SelectionForeColor
        Get
            Return _SelectionForeColor
        End Get
        Set(ByVal value As System.Drawing.Color)
            _SelectionForeColor = value
        End Set
    End Property

    Public Property Id() As Integer Implements IPosition.Id
        Get
            Return _Id
        End Get
        Set(ByVal value As Integer)
            _Id = value
        End Set
    End Property

    Public Property IsManaging() As Boolean Implements IPosition.IsManaging
        Get
            Return _IsManaging
        End Get
        Set(ByVal value As Boolean)
            _IsManaging = value
        End Set
    End Property

    Public Property PositionDesription() As String Implements IPosition.PositionDesription
        Get
            Return _PositionDesription
        End Get
        Set(ByVal value As String)
            _PositionDesription = value
        End Set
    End Property

    Public Shadows ReadOnly Property ToString() As String Implements IDatagridViewColorScheme.ToString
        Get
            Return _PositionDesription
        End Get
        
    End Property
End Class
Continue at my next post....