Display ListView onMouseClick event

M

Mad Joe

Hello!

Can someone help me, please? It's 6am, I don't have concentration,
feel desperate and I have a deadLine for my project (exam at my
university)..

How can I display ListView onMouse Click event?

Let's say that I just need a detailed view of columnHeaders. Somewhere
in my code there is already prepared array:

ArrayOfCharacters - definition of the columns of my ListView.

This is something I've done so far (I call function DrawTable
onMouseClick event):


public class GenDKA : System.Windows.Forms.UserControl

private System.Windows.Forms.ListView listViewDKA;

[... <cut> ...]

protected override void Dispose (bool disposing)
{
if (disposing)
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose (disposing);
}

private void InitializeComponent()
{
this.Name = "GenDKA";
this.Size = new System.Drawing.Size(504, 248);
this.listViewDKA = new System.Windows.Forms.ListView();

this.listViewDKA.GridLines = true;
this.listViewDKA.HeaderStyle =
System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listViewDKA.Location = new System.Drawing.Point(8, 8);
this.listViewDKA.Name = "listViewDKA";
this.listViewDKA.Size = new System.Drawing.Size(488, 232);
this.listViewDKA.TabIndex = 0;
this.listViewDKA.View = System.Windows.Forms.View.Details;
}

public void DrawTable()
{
ListView listViewDKA = new ListView();

listViewDKA.Items.Clear();
ListViewItem item = new ListViewItem("NewItem");
item.UseItemStyleForSubItems = false;

for (int i = 0; i < ArrayOfCharacters.Count; i++)
{
MessageBox.Show(ArrayOfCharacters.ToString());
listViewDKA.Columns.Add(new ColumnHeader());
listViewDKA.Columns.Text = ArrayOfCharacters.ToString();
listViewDKA.Columns.Width = 25;
}
listViewDKA.View = View.Details;
this.Controls.Add(listViewDKA);
}

public GenDKA()
{
InitializeComponent();
}

}
 
M

Mark Johnson

I think you are forgetting to set the event.
I am not sure what the MouseClick looks like at the moment but this is how
the ColumnClick would jook like.
Add it to your Methedos InitializeComponent() and DrawTable
listViewListen.ColumnClick += new
System.Windows.Forms.ColumnClickEventHandler(this.DrawTable);

Hope this helps
Mark Johnson, Berlin Germany
(e-mail address removed)
 
M

Mad Joe

Thank you Mark!

I solved the problem the next morning. I guess that for this mistake I
could blame my lack of sleep... Thanks anyway! :)

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top