?? objectlistview.cs
字號:
}
/// <summary>
/// Get the ListViewItem that is currently selected . If no row is selected, or more than one is selected, return null.
/// </summary>
[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual ListViewItem SelectedItem
{
get {
if (this.SelectedIndices.Count == 1)
return this.GetItem(this.SelectedIndices[0]);
else
return null;
}
set {
this.SelectedIndices.Clear();
if (value != null)
this.SelectedIndices.Add(value.Index);
}
}
/// <summary>
/// Get the model object from the currently selected row. If no row is selected, or more than one is selected, return null.
/// Select the row that is displaying the given model object. All other rows are deselected.
/// </summary>
[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual Object SelectedObject
{
get { return this.GetSelectedObject(); }
set { this.SelectObject(value); }
}
/// <summary>
/// Get the model objects from the currently selected rows. If no row is selected, the returned List will be empty.
/// When setting this value, select the rows that is displaying the given model objects. All other rows are deselected.
/// </summary>
[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual IList SelectedObjects
{
get { return this.GetSelectedObjects(); }
set { this.SelectObjects(value); }
}
/// <summary>
/// Should the list view show a bitmap in the column header to show the sort direction?
/// </summary>
/// <remarks>
/// The only reason for not wanting to have sort indicators is that, on pre-XP versions of
/// Windows, having sort indicators required the ListView to have a small image list, and
/// as soon as you give a ListView a SmallImageList, the text of column 0 is bumped 16
/// pixels to the right, even if you never used an image.
/// </remarks>
[Category("Behavior - ObjectListView"),
Description("Should the list view show sort indicators in the column headers?"),
DefaultValue(true)]
public virtual bool ShowSortIndicators
{
get { return showSortIndicators; }
set { showSortIndicators = value; }
}
private bool showSortIndicators;
/// <summary>
/// Should the list view show images on subitems?
/// </summary>
/// <remarks>
/// <para>Virtual lists have to be owner drawn in order to show images on subitems?</para>
/// </remarks>
[Category("Behavior - ObjectListView"),
Description("Should the list view show images on subitems?"),
DefaultValue(false)]
public virtual bool ShowImagesOnSubItems
{
get {
#if MONO
return false;
#else
return showImagesOnSubItems;
#endif
}
set {
showImagesOnSubItems = value;
if (value && this.VirtualMode)
this.OwnerDraw = true;
}
}
private bool showImagesOnSubItems;
/// <summary>
/// This property controls whether group labels will be suffixed with a count of items.
/// </summary>
/// <remarks>
/// The format of the suffix is controlled by GroupWithItemCountFormat/GroupWithItemCountSingularFormat properties
/// </remarks>
[Category("Behavior - ObjectListView"),
Description("Will group titles be suffixed with a count of the items in the group?"),
DefaultValue(false)]
public virtual bool ShowItemCountOnGroups
{
get { return showItemCountOnGroups; }
set { showItemCountOnGroups = value; }
}
private bool showItemCountOnGroups;
/// <summary>
/// Override the SmallImageList property so we can correctly shadow its operations.
/// </summary>
/// <remarks><para>If you use the RowHeight property to specify the row height, the SmallImageList
/// must be fully initialised before setting/changing the RowHeight. If you add new images to the image
/// list after setting the RowHeight, you must assign the imagelist to the control again. Something as simple
/// as this will work:
/// <code>listView1.SmallImageList = listView1.SmallImageList;</code></para>
/// </remarks>
new public ImageList SmallImageList
{
get { return this.shadowedImageList; }
set {
this.shadowedImageList = value;
this.SetupExternalImageList();
}
}
private ImageList shadowedImageList = null;
/// <summary>
/// When the listview is grouped, should the items be sorted by the primary column?
/// If this is false, the items will be sorted by the same column as they are grouped.
/// </summary>
[Category("Behavior - ObjectListView"),
Description("When the listview is grouped, should the items be sorted by the primary column? If this is false, the items will be sorted by the same column as they are grouped."),
DefaultValue(true)]
public virtual bool SortGroupItemsByPrimaryColumn
{
get { return this.sortGroupItemsByPrimaryColumn; }
set { this.sortGroupItemsByPrimaryColumn = value; }
}
private bool sortGroupItemsByPrimaryColumn = true;
/// <summary>
/// Should each row have a tri-state checkbox?
/// </summary>
/// <remarks>
/// If this is true, the user can choose the third state (normally Indeterminate). Otherwise, user clicks
/// alternate between checked and unchecked. CheckStateGetter can still return Indeterminate when this
/// setting is false.
/// </remarks>
[Category("Behavior - ObjectListView"),
Description("Should the primary column have a checkbox that behaves as a tri-state checkbox?"),
DefaultValue(false)]
public virtual bool TriStateCheckBoxes {
get { return triStateCheckBoxes; }
set {
triStateCheckBoxes = value;
if (value && !this.CheckBoxes)
this.CheckBoxes = true;
this.InitializeStateImageList();
}
}
private bool triStateCheckBoxes;
/// <summary>
/// Get or set the index of the top item of this listview
/// </summary>
/// <remarks>
/// <para>
/// This property only works when the listview is in Details view and not showing groups.
/// </para>
/// <para>
/// The reason that it does not work when showing groups is that, when groups are enabled,
/// the Windows m LVM_GETTOPINDEX always returns 0, regardless of the
/// scroll position.
/// </para>
/// </remarks>
[Browsable(false),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual int TopItemIndex
{
get {
if (this.View == View.Details && this.TopItem != null)
return this.TopItem.Index;
else
return -1;
}
set {
int newTopIndex = Math.Min(value, this.GetItemCount() - 1);
if (this.View == View.Details && newTopIndex >= 0) {
this.TopItem = this.Items[newTopIndex];
// Setting the TopItem sometimes gives off by one errors,
// that (bizarrely) are correct on a second attempt
if (this.TopItem != null && this.TopItem.Index != newTopIndex)
this.TopItem = this.GetItem(newTopIndex);
}
}
}
/// <summary>
/// When resizing a column by dragging its divider, should any space filling columns be
/// resized at each mouse move? If this is false, the filling columns will be
/// updated when the mouse is released.
/// </summary>
/// <remarks>
/// <para>
/// In previous versions, setting this to true produced ugly behaviour, because every
/// column to the right of the divider being dragged was updated twice: once when
/// the column be resized changes size (this moves all the columns slightly to the right);
/// then again when the filling columns are updated - they are shrunk
/// so that the combined width is not more than the control, so everything jumps slightly back to the left again.
/// </para>
/// <para>
/// But, as of v2.0, the change the Windows messages in place, so there is now only one update,
/// and everything looks nice and smooth.
/// </para>
/// <para>
/// However, it still looks odd when the space filling column
/// is in the left of the column that is being resized: the right edge of the column is dragged, but
/// its <b>left</b> edge moves, since the space filling column is shrinking.
/// </para>
/// <para>Given the above behavior is probably best to turn this property off if your space filling
/// columns aren't the right-most columns.</para>
/// </remarks>
[Category("Behavior - ObjectListView"),
Description("When resizing a column by dragging its divider, should any space filling columns be resized at each mouse move?"),
DefaultValue(true)]
public virtual bool UpdateSpaceFillingColumnsWhenDraggingColumnDivider
{
get { return updateSpaceFillingColumnsWhenDraggingColumnDivider; }
set { updateSpaceFillingColumnsWhenDraggingColumnDivider = value; }
}
private bool updateSpaceFillingColumnsWhenDraggingColumnDivider = true;
/// <summary>
/// Should the list give a different background color to every second row?
/// </summary>
/// <remarks><para>The color of the alternate rows is given by AlternateRowBackColor.</para>
/// <para>There is a "feature" in .NET for listviews in non-full-row-select mode, where
/// selected rows are not drawn with their correct background color.</para></remarks>
[Category("Appearance"),
Description("Should the list view use a different backcolor to alternate rows?"),
DefaultValue(false)]
public virtual bool UseAlternatingBackColors
{
get { return useAlternatingBackColors; }
set { useAlternatingBackColors = value; }
}
private bool useAlternatingBackColors;
/// <summary>
/// Should the selected row be drawn with non-standard foreground and background colors?
/// </summary>
/// <remarks>
/// When this is enabled, the control becomes owner drawn.
/// </remarks>
[Category("Appearance"),
Description("Should the selected row be drawn with non-standard foreground and background colors?"),
DefaultValue(false)]
public bool UseCustomSelectionColors
{
get { return this.useCustomSelectionColors; }
set {
this.useCustomSelectionColors = value;
if (!this.DesignMode && value)
this.OwnerDraw = true;
}
}
private bool useCustomSelectionColors;
/// <summary
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -