Search code examples
c#objectlistview

How can i select all the row in ObjectListView?


I'm using ObjectListView in winforms application, and i encountered a problem, in my List i wont if i click on any column of my row it should be selected (all the row).

this is my code:

olvSongs.AllColumns.Add(this.titleColumn);
olvSongs.AllColumns.Add(this.typeColumn);
olvSongs.AllColumns.Add(this.addedColumn);
olvSongs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            | System.Windows.Forms.AnchorStyles.Left)
            | System.Windows.Forms.AnchorStyles.Right)));
olvSongs.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.titleColumn,
this.typeColumn,
this.addedColumn});
olvSongs.Location = new System.Drawing.Point(6, 40);
olvSongs.Name = "olvSongs";
olvSongs.ShowGroups = false;
olvSongs.Size = new System.Drawing.Size(638, 190);
olvSongs.SmallImageList = this.imageList1;
olvSongs.TabIndex = 7;
olvSongs.UseAlternatingBackColors = true;
olvSongs.UseCompatibleStateImageBehavior = false;
olvSongs.UseFiltering = true;
olvSongs.View = System.Windows.Forms.View.Details;

here i can select the row only if i select titleColumn.

this is picture to demonstrate what i get (the selection only on the first column):

enter image description here


Solution

  • It is a little bit unclear what you want to achieve., But if you are talking about this

    enter image description here

    VS this

    enter image description here

    you have to set

    olvSongs.FullRowSelect = true;
    

    If thats not what you mean please improve your question.