space – Owl's Blog on .NET development http://www.componentowl.com/blog Component Owl codes Better ListView control all night so you don't have to. Tue, 04 Sep 2018 13:10:05 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 How to Add Grid Lines in Empty Space in Better ListView http://www.componentowl.com/blog/how-to-add-grid-lines-in-empty-space-in-better-listview/ http://www.componentowl.com/blog/how-to-add-grid-lines-in-empty-space-in-better-listview/#respond Wed, 30 Apr 2014 09:51:46 +0000 http://www.componentowl.com/blog/?p=894 Default list without grid lines below items

Default list without grid lines below items

List with grid lines added

List with grid lines added

Setting grid lines in Better ListView is easy. Simply make sure you are using Details view (the default view). Then you can set GridLines property to one of the following values:

  • None – grid lines are hidden
  • Horizontal – only horizontal lines are displayed
  • Vertical – only vertical lines are displayed
  • Grid – both horizontal and vertical lines are displayed, forming a grid

None of these settings, however, cause drawing lines below the last visible item, which may be desirable. The reason for this is that Better ListView supports custom item height and there is uncertainity about the spacing between new grid lines (smallest?, largest?, average?) It is up to your choice.

To draw new grid lines, handle the DrawBackground event (or subclass BetterListView and override the OnDrawBackground method) with the following code:

[csharp gutter=”false” toolbar=”false”]
private void ListViewOnDrawBackground(object sender, BetterListViewDrawBackgroundEventArgs eventArgs)
{
BetterListView listView = (BetterListView)sender;

// get last visible item
var item = listView.BottomItem;

if (item == null)
{
return;
}

// measure row height
var bounds = listView.GetItemBounds(item);
int rowHeight = bounds.BoundsOuterExtended.Height;

// draw additional lines
Rectangle rectClient = listView.ClientRectangleInner;
Pen penGridLines = new Pen(listView.ColorGridLines, 1.0f);

int y = (bounds.BoundsOuterExtended.Bottom + rowHeight);

while (y < rectClient.Bottom) { eventArgs.Graphics.DrawLine( penGridLines, rectClient.Left, y, rectClient.Right - 1, y); y += rowHeight; } penGridLines.Dispose(); } [/csharp] What this code does is getting the last visible item using BottomItem property. It is importantĀ  to get this visible item instead of e.g. first item because GetItemBounds method returns non-null value on visible items only. The GetItemBounds method reveals item measurement which is used to determine item height and coordinate of its bottom. Finally, we draw new lines using current grid line colorĀ  (ColorGridLines property) until reaching the bottom of the view.

]]>
http://www.componentowl.com/blog/how-to-add-grid-lines-in-empty-space-in-better-listview/feed/ 0
Custom Item Height in Details View of Better ListView http://www.componentowl.com/blog/custom-item-height-in-details-view-of-better-listview/ http://www.componentowl.com/blog/custom-item-height-in-details-view-of-better-listview/#respond Wed, 21 Mar 2012 15:10:52 +0000 http://www.componentowl.com/blog/?p=760 Better ListView 2.7.0.0 now supports items of arbitrary height in Details view:

Items with custom height

Items with custom height

Items with variable heights were possible in recent versions of Better ListView as well, but this adjustment was limited to heights which are multiples of text line height.

We have introduced a BetterListViewItem.CustomHeight property, which is 0 by default.

Every item has some minimum size (defined by the font and image) but it can get arbitrarily larger. The following formula explains how item height is measured in Better ListView:

height = max(minimum height, image height, text height, custom height)

Setting minimum height for all items is possible through layout properties and the latter is defined by the item itself.

]]>
http://www.componentowl.com/blog/custom-item-height-in-details-view-of-better-listview/feed/ 0
Custom Spacing between Items in Details View http://www.componentowl.com/blog/custom-spacing-between-items-in-details-view/ http://www.componentowl.com/blog/custom-spacing-between-items-in-details-view/#respond Tue, 13 Mar 2012 22:53:09 +0000 http://www.componentowl.com/blog/?p=753 Better ListView 2.6 newly supports custom spacing between items in Details view:

Custom Spacing between Items

Custom Spacing between Items

This property has been recently available in other views, but Details view was exception since its selections needed to be treated in different way: They overlap by 1 pixel so that the double border is avoided in neighboring selections:

1 px overlap of items

1 px overlap of items

We have resolved this to get proper behavior with custom spacings and now the spacing can be set the same way as in any other view:

Simply set LayoutItemsCurrent.ElementOuterPadding to have custom horizontal and vertical padding between items.

You can set this specifically for Details view by refering to property LayoutItemsDetails or LayoutItemsDetailsColumns (Details view with columns).

]]>
http://www.componentowl.com/blog/custom-spacing-between-items-in-details-view/feed/ 0