Click or drag to resize

JamBaseShellListViewCreatedColumns Event

This event is fired after the columns were created.

Namespace:  Jam.Shell
Assembly:  ShellBrowser.Winforms (in ShellBrowser.Winforms.dll) Version: 6.3.1
Syntax
public event EventHandler CreatedColumns

Value

Type: SystemEventHandler
Remarks
You can use this event to control the columns that are shown in the list. If however you remove the ShellColumnName column it will be reinserted again.
Examples
This example adds custom columns in the CreatedColumns event.
C#
private void ShellListView_CreatedColumns(object sender, EventArgs e)
{
    // add a column for the path length
    JamShellColumnHeader lCol = new JamShellColumnHeader();
    lCol.Text = cPathLengthString;
    lCol.TextAlign = HorizontalAlignment.Right;
    lCol.Width = 85;
    shellListView1.Columns.Add(lCol);
    lCol.DisplayIndex = 1; //if you want a different position for your column use the DisplayIndex.



    // add a column for the link target
    lCol = new JamShellColumnHeader();
    lCol.Text = cLinkTargetString;
    // the link target is a full path so we need a large column
    lCol.Width = 350;
    shellListView1.Columns.Add(lCol);
}

private void ShellListView_AddItem(object sender, Jam.Shell.AddItemEventArgs e)
{
    //The AddItem is called for every item that is added to the list. You need to provide values for the custom columns.
    //Add the subitems in the same order the columns were added (the index of column and subItems must match).

    // get the path length
    string lLength = e.Item.FullPath.Length.ToString(System.Globalization.CultureInfo.CurrentCulture);
    // add the path length as subitem
    e.Item.SubItems.Add(lLength);

    // check whether the item is a link
    // note: the next few lines are just used for illustrative purposes.
    // the retrieval of the link target may take some time for large file lists
    string lLinkTarget = ShellBrowser.GetLinkTarget(e.Item.FullPath);
    // add the link target as subitem (if it`s not a link, an empty string was returned)
    e.Item.SubItems.Add(lLinkTarget);
}
Examples
This example re-initializes the columns displayed for MyMusic in the CreatedColumns event.
C#
private void ShellListView1_CreatedColumns(object sender, EventArgs e)
{
    if (shellListView1.SpecialFolder == ShellFolder.MyMusic)
    {
        shellListView1.BeginUpdate();
        shellListView1.Columns.Clear(); //name column it will be reinserted again automatically.
        shellListView1.Columns.Show(SHCOLUMNID.ShellColumnSummaryTitle);
        //displays the column at the default position.
        shellListView1.Columns.Show(SHCOLUMNID.ShellColumnMusicAlbum);
        shellListView1.Columns.Show(SHCOLUMNID.ShellColumnMusicArtist);
        shellListView1.Columns.Add(SHCOLUMNID.ShellColumnMusicGenre); //adds the column at the end.

        shellListView1.EndUpdate();
    }
}
See Also