Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ListView selected item
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01377334
Message ID:
01377344
Vues:
29
This message has been marked as the solution to the initial question of the thread.
Hi Einar,

You will have to owner draw your listview items. You will need to set the OwnerDraw property on the listview and then hookup to the DrawItem event:-

http://msdn.microsoft.com/en-us/library/system.windows.forms.drawlistviewitemeventargs(VS.80).aspx

The bit you are interested in is the state of the row which you can use the ListViewItemStates enumeration to determine.
private void listView1_DrawItem(object sender,
    DrawListViewItemEventArgs e)
{
    if ((e.State & ListViewItemStates.Selected) != 0)
    {
        // Draw the background and focus rectangle for a selected item.
        e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
        e.DrawFocusRectangle();
    }
    else
    {
        // Draw the background for an unselected item.
        using (LinearGradientBrush brush =
            new LinearGradientBrush(e.Bounds, Color.Orange,
            Color.Maroon, LinearGradientMode.Horizontal))
        {
            e.Graphics.FillRectangle(brush, e.Bounds);
        }
    }

    // Draw the item text for views other than the Details view.
    if (listView1.View != View.Details)
    {
        e.DrawText();
    }
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform