Display ListView onMouseClick event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mad Joe

    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:

    ArrayOfCharacte rs - 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.UserContr ol

    private System.Windows. Forms.ListView listViewDKA;

    [... <cut> ...]

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

    private void InitializeCompo nent()
    {
    this.Name = "GenDKA";
    this.Size = new System.Drawing. Size(504, 248);
    this.listViewDK A = new System.Windows. Forms.ListView( );

    this.listViewDK A.GridLines = true;
    this.listViewDK A.HeaderStyle =
    System.Windows. Forms.ColumnHea derStyle.Noncli ckable;
    this.listViewDK A.Location = new System.Drawing. Point(8, 8);
    this.listViewDK A.Name = "listViewDK A";
    this.listViewDK A.Size = new System.Drawing. Size(488, 232);
    this.listViewDK A.TabIndex = 0;
    this.listViewDK A.View = System.Windows. Forms.View.Deta ils;
    }

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

    listViewDKA.Ite ms.Clear();
    ListViewItem item = new ListViewItem("N ewItem");
    item.UseItemSty leForSubItems = false;

    for (int i = 0; i < ArrayOfCharacte rs.Count; i++)
    {
    MessageBox.Show (ArrayOfCharact ers[i].ToString());
    listViewDKA.Col umns.Add(new ColumnHeader()) ;
    listViewDKA.Col umns[i].Text = ArrayOfCharacte rs[i].ToString();
    listViewDKA.Col umns[i].Width = 25;
    }
    listViewDKA.Vie w = View.Details;
    this.Controls.A dd(listViewDKA) ;
    }

    public GenDKA()
    {
    InitializeCompo nent();
    }

    }
  • Mark Johnson

    #2
    Re: Display ListView onMouseClick event

    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 InitializeCompo nent() and DrawTable
    listViewListen. ColumnClick += new
    System.Windows. Forms.ColumnCli ckEventHandler( this.DrawTable) ;

    Hope this helps
    Mark Johnson, Berlin Germany
    mj10777@mj10777 .de




    "Mad Joe" <joe@net.hr> schrieb im Newsbeitrag
    news:66f44b7b.0 311160343.789ec 33@posting.goog le.com...[color=blue]
    > 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:
    >
    > ArrayOfCharacte rs - 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.UserContr ol
    >
    > private System.Windows. Forms.ListView listViewDKA;
    >
    > [... <cut> ...]
    >
    > protected override void Dispose (bool disposing)
    > {
    > if (disposing)
    > {
    > if(components != null)
    > {
    > components.Disp ose();
    > }
    > }
    > base.Dispose (disposing);
    > }
    >
    > private void InitializeCompo nent()
    > {
    > this.Name = "GenDKA";
    > this.Size = new System.Drawing. Size(504, 248);
    > this.listViewDK A = new System.Windows. Forms.ListView( );
    >
    > this.listViewDK A.GridLines = true;
    > this.listViewDK A.HeaderStyle =
    > System.Windows. Forms.ColumnHea derStyle.Noncli ckable;
    > this.listViewDK A.Location = new System.Drawing. Point(8, 8);
    > this.listViewDK A.Name = "listViewDK A";
    > this.listViewDK A.Size = new System.Drawing. Size(488, 232);
    > this.listViewDK A.TabIndex = 0;
    > this.listViewDK A.View = System.Windows. Forms.View.Deta ils;
    > }
    >
    > public void DrawTable()
    > {
    > ListView listViewDKA = new ListView();
    >
    > listViewDKA.Ite ms.Clear();
    > ListViewItem item = new ListViewItem("N ewItem");
    > item.UseItemSty leForSubItems = false;
    >
    > for (int i = 0; i < ArrayOfCharacte rs.Count; i++)
    > {
    > MessageBox.Show (ArrayOfCharact ers[i].ToString());
    > listViewDKA.Col umns.Add(new ColumnHeader()) ;
    > listViewDKA.Col umns[i].Text = ArrayOfCharacte rs[i].ToString();
    > listViewDKA.Col umns[i].Width = 25;
    > }
    > listViewDKA.Vie w = View.Details;
    > this.Controls.A dd(listViewDKA) ;
    > }
    >
    > public GenDKA()
    > {
    > InitializeCompo nent();
    > }
    >
    > }[/color]


    Comment

    • Mad Joe

      #3
      Re: Display ListView onMouseClick event

      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" <mj10777@mj1077 7.de> wrote in message news:<3fb7a2f0$ 0$11878$9b4e6d9 3@newsread2.arc or-online.net>...[color=blue]
      > 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 InitializeCompo nent() and DrawTable
      > listViewListen. ColumnClick += new
      > System.Windows. Forms.ColumnCli ckEventHandler( this.DrawTable) ;
      >
      > Hope this helps
      > Mark Johnson, Berlin Germany
      > mj10777@mj10777 .de[/color]

      Comment

      Working...