You again omit some information but perhaps this can help you.
With the code below you can fill your content array as you like and
directly assign a background and a foreground color to your content.
After doing so, you set the number of columnheaders you like.
The listview is then filled always from left to right from top to bottom.
This is of course just a minimal version but I think it is easy to expand
this code to be a bit more sophisticated ;-)
private void Form1_Load(obje ct sender, System.EventArg s e)
{
// 1. Prepare content somehow
int contentCount = 12;
Content[] content = new Content[contentCount];
content[0] = new Content("the cat", Color.Black, Color.Aquamarin e);
content[1] = new Content("jumped ", Color.Cornflowe rBlue, Color.Wheat);
content[2] = new Content("over", Color.Black, Color.Beige);
content[3] = new Content("the wall", Color.Cornflowe rBlue, Color.Aquamarin e);
content[4] = new Content("the cat", Color.Black, Color.Aquamarin e);
content[5] = new Content("jumped ", Color.Black, Color.Beige);
content[6] = new Content("over", Color.Yellow, Color.Blue);
content[7] = new Content("the wall", Color.Cornflowe rBlue, Color.Red);
content[8] = new Content("jumped ", Color.Cornflowe rBlue, Color.Red);
content[9] = new Content("the dog", Color.SeaGreen, Color.DarkViole t);
content[10] = new Content("the bird", Color.YellowGre en, Color.SaddleBro wn);
content[11] = new Content("the fox", Color.Black, Color.White);
// Number of cells you want
// = Number of Column Headers
int cellCount = 3;
// Create and add items
for (int i=0; i<contentCount ; i=i+cellCount)
{
ListViewItem lvi = new ListViewItem(co ntent[i].text);
lvi.UseItemStyl eForSubItems = false;
for (int c=1; c<cellCount; c++)
lvi.SubItems.Ad d(content[i+c].text, content[i+c].c1, content[i+c].c2, new Font("Arial", 8));
this.listView1. Items.Add(lvi);
}
}
Hope this helps!
Greetings,
timtos.
"Patrick De Ridder" <00*@000.00> wrote in message news:10******** *******@evisp-news-01.ops.asmr-01.energis-idc.net...
Below a rather simplistic example of a list view routine.
Say I want to have "over" appearing in red on the
display, how would I do that?
Many thanks,
Patrick.
pa************* **@hetnet.nl
*************** ************
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
\namespace WindowsApplicat ion1
{
public class Form1 : System.Windows. Forms.Form
{
private System.Windows. Forms.ListView listView1;
private System.Windows. Forms.ColumnHea der columnHeader1;
private System.Windows. Forms.ColumnHea der columnHeader2;
private System.Componen tModel.Containe r components = null;
public Form1()
{
InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region
#endregion
static void Main()
{
Application.Run (new Form1());
}
private void Form1_Load(obje ct sender, System.EventArg s e)
{
string [] content = new string [4];
string [] show = new string [2];
content [0] = "the cat";
content[1] = "jumped ";
content [2] = "over";
content[3] = "the wall";
int k = -1;
for (int i=0 ;i<2;i++)
{
show [0] = content[++k];
show[1] = content [++k];
ListViewItem list = new ListViewItem(sh ow);
listView1.Items .Add(list);
}
}
}
}