[ erkan @ 12.08.2005. 10:53 ] @
Pozdrav svima,
jedno 'obicno' pitanje.
Nije mi jasno zasto se ne moze postaviti
boja (Back ili ForeColor) SubItem-a u ListView-u?

[pisem napamet]:

Code:

  // Ovaj dio radi:
  lvPrimjer.Items[0].BackColor = System.Color.Ivory;
  lvPrimjer.Items[0].ForeColor = System.Color.Red;  

  // sljedeci kod nema efekta:
  lvPrimjer.Items[0].SubItems[0].BackColor = System.Color.Red;
  lvPrimjer.Items[0].SubItems[0].ForeColor = System.Color.White;  


Dakle, izmjena boje cijelog Item-a (reda) uspjeva, a kada se pokusa izmjeniti boja samo
jedne celije (SubItem-a) onda ne radi. Ne prijevljuje gresku, ali nema efekta!?
[ Steki_73 @ 12.08.2005. 23:51 ] @
Klasičan bug Microsoft-a. Vidi link:

http://www.kbalertz.com/Feedback_814734.aspx

Pozdrav!
[ radoica @ 13.08.2005. 22:10 ] @
UseItemStyleForSubItems mora biti postavljeno na False. Po default-u je postavljeno na True.
[ erkan @ 15.08.2005. 07:31 ] @
vidi, stvarno bug, hvala Steki, konacno da skontam u cemu je problem.
Radoice, nije mi jasno,
Citat:
radoica: UseItemStyleForSubItems mora biti postavljeno na False. Po default-u je postavljeno na True.

nisam uspio da nadjem taj property, ne znam o cemu se radi.
-------------------------------------------------------------------------------
(Valjda je MS u 2.0 ispravio bug)

[Ovu poruku je menjao erkan dana 15.08.2005. u 08:36 GMT+1]
[ nervozica @ 15.08.2005. 08:10 ] @
baci pogled:
http://msdn.microsoft.com/libr...eitemstyleforsubitemstopic.asp
[ erkan @ 15.08.2005. 08:31 ] @
Odlicno, probao i radi!
Radoica, Nervozica, hvala vam.
Evo koda sa gornjeg linka:

Code:

// Declare the Listview object.
    internal System.Windows.Forms.ListView myListView;

    // Initialize the ListView object with subitems of a different
    // style than the default styles for the ListView.
    private void InitializeListView()
    {

        // Set the Location, View and Width properties for the 
        // ListView object. 
        myListView = new ListView();
        myListView.Location = new System.Drawing.Point(20, 20);
        myListView.Width = 250;

        // The View property must be set to Details for the 
        // subitems to be visible.
        myListView.View = View.Details;
        
        // Each SubItem object requires a column, so add three columns.
        this.myListView.Columns.Add("Key", 50, HorizontalAlignment.Left);
        this.myListView.Columns.Add("A", 100, HorizontalAlignment.Left);
        this.myListView.Columns.Add("B", 100, HorizontalAlignment.Left);

        // Add a ListItem object to the ListView.
        ListViewItem entryListItem = myListView.Items.Add("Items");

        // Set UseItemStyleForSubItems property to false to change 
        // look of subitems.
       entryListItem.UseItemStyleForSubItems = false; 

        // Add the expense subitem.
        ListViewItem.ListViewSubItem expenseItem = 
            entryListItem.SubItems.Add("Expense");

        // Change the expenseItem object's color and font.
        expenseItem.ForeColor = System.Drawing.Color.Red;
        expenseItem.Font = new System.Drawing.Font(
            "Arial", 10, System.Drawing.FontStyle.Italic);

        // Add a subitem called revenueItem 
        ListViewItem.ListViewSubItem revenueItem = 
            entryListItem.SubItems.Add("Revenue");

        // Change the revenueItem object's color and font.
        revenueItem.ForeColor = System.Drawing.Color.Blue;
        revenueItem.Font = new System.Drawing.Font(
            "Times New Roman", 10, System.Drawing.FontStyle.Bold);

        // Add the ListView to the form.
        this.Controls.Add(this.myListView);
    }


pozdrav!