473,414 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Display ListView onMouseClick event

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.Nonclickabl e;
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[i].ToString());
listViewDKA.Columns.Add(new ColumnHeader());
listViewDKA.Columns[i].Text = ArrayOfCharacters[i].ToString();
listViewDKA.Columns[i].Width = 25;
}
listViewDKA.View = View.Details;
this.Controls.Add(listViewDKA);
}

public GenDKA()
{
InitializeComponent();
}

}
Nov 15 '05 #1
2 4183
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
mj*****@mj10777.de


"Mad Joe" <jo*@net.hr> schrieb im Newsbeitrag
news:66*************************@posting.google.co m...
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.Nonclickabl e;
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[i].ToString());
listViewDKA.Columns.Add(new ColumnHeader());
listViewDKA.Columns[i].Text = ArrayOfCharacters[i].ToString();
listViewDKA.Columns[i].Width = 25;
}
listViewDKA.View = View.Details;
this.Controls.Add(listViewDKA);
}

public GenDKA()
{
InitializeComponent();
}

}

Nov 15 '05 #2
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
"Mark Johnson" <mj*****@mj10777.de> wrote in message news:<3f***********************@newsread2.arcor-online.net>...
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
mj*****@mj10777.de

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tee | last post by:
Hi, I have a listview control that has a column displaying path. I need to change the StringTrimming of text in this column to StringTrimming.EllipsisPath, but there is no paint event available...
1
by: Danny | last post by:
I have this code below to do a rollover image. IT doesnt work with the onmouseclick event. But it wil lwork fine with the onmouseover so when the user hovers over the image, the main image...
3
by: andrewcw | last post by:
I have a simple winform with the following code. But although I can read back the info, the display fails to provide the text or the cell background color changes. private void ListViewBroke()...
1
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row...
0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
2
by: amber | last post by:
Hello I have a listview that displays a list of choices When the mouse moves over each item, I would like text (the name of the item that is being hovered over) to show u in a seperate label or...
0
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
3
by: phpfreak2007 | last post by:
Hello All,,, I am using Following code to change the back color of list view. I don't want the Windows default gray color when Listview is Enable false.so I have crated one class by inheriting ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.