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(object sender, System.EventArgs e)
{
// 1. Prepare content somehow
int contentCount = 12;
Content[] content = new Content[contentCount];
content[0] = new Content("the cat", Color.Black, Color.Aquamarine);
content[1] = new Content("jumped", Color.CornflowerBlue, Color.Wheat);
content[2] = new Content("over", Color.Black, Color.Beige);
content[3] = new Content("the wall", Color.CornflowerBlue, Color.Aquamarine);
content[4] = new Content("the cat", Color.Black, Color.Aquamarine);
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.CornflowerBlue, Color.Red);
content[8] = new Content("jumped", Color.CornflowerBlue, Color.Red);
content[9] = new Content("the dog", Color.SeaGreen, Color.DarkViolet);
content[10] = new Content("the bird", Color.YellowGreen, Color.SaddleBrown);
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(content[i].text);
lvi.UseItemStyleForSubItems = false;
for (int c=1; c<cellCount; c++)
lvi.SubItems.Add(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.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
\namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region
#endregion
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs 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(show);
listView1.Items.Add(list);
}
}
}
}