generate barcode in crystal report GRA PHICS AN D G RAPHIC AL US ER INTERFA CES in VB.NET

Generator Quick Response Code in VB.NET GRA PHICS AN D G RAPHIC AL US ER INTERFA CES

CHAPTER 11 GRA PHICS AN D G RAPHIC AL US ER INTERFA CES
QR Maker In VB.NET
Using Barcode drawer for VS .NET Control to generate, create Quick Response Code image in .NET applications.
www.OnBarcode.com
Recognize QR In VB.NET
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
Figure 11-38. A text list box
Code 128B Generation In Visual Basic .NET
Using Barcode generator for VS .NET Control to generate, create Code 128 Code Set B image in Visual Studio .NET applications.
www.OnBarcode.com
Data Matrix 2d Barcode Creation In VB.NET
Using Barcode generation for .NET framework Control to generate, create ECC200 image in Visual Studio .NET applications.
www.OnBarcode.com
Highlighting Selected Items
Barcode Creation In VB.NET
Using Barcode creation for .NET framework Control to generate, create Barcode image in VS .NET applications.
www.OnBarcode.com
Print Barcode In Visual Basic .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
The ListBox and ListBoxItem classes are designed for a very generic usage and, therefore, provide no built-in support for highlighting selected items. You need to implement this by yourself. The approach in this section allows a high level of flexibility. You can change the appearance of the newly selected item and previously selected item in the SelectionChanged handler of the ListBox class. A better approach is to derive a custom list box item that is able to highlight itself. The ListBoxItem class provides a virtual OnIsSelectedChanged method that you can override to change the appearance of your item when it was selected or deselected. Listing 11-29 shows the implementation of the custom HighlightableListBoxItem class. This item changes the background to blue when it is selected. When it is not selected, no background will be drawn, so that it is transparent and displays the background of the list box. The list box item will again accept any UIElement as its child content, so it provides a constructor that allows you to pass the content directly. You can use the custom list box item in Listing 11-29 with Listing 11-28, with minor code changes, to see highlighted selected list box items, as shown in Figure 11-39. ListBox listBox = new ListBox(); for (int i = 0; i < 10; ++i) { string str = "Item " + i.ToString() + ". Hello World."; ListBoxItem item = new HighlightableListBoxItem(new Text(font, str)); listBox.Items.Add(item); }
QR Code ISO/IEC18004 Generation In VB.NET
Using Barcode generation for Visual Studio .NET Control to generate, create QR Code image in VS .NET applications.
www.OnBarcode.com
Encode ANSI/AIM ITF 25 In Visual Basic .NET
Using Barcode printer for .NET framework Control to generate, create 2/5 Interleaved image in .NET framework applications.
www.OnBarcode.com
Figure 11-39. Highlighting the selected item
Generating QR-Code In Objective-C
Using Barcode printer for iPad Control to generate, create QR image in iPad applications.
www.OnBarcode.com
Quick Response Code Decoder In VB.NET
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
C HAPT ER 11 GRAPHICS AND GRA PHICA L USE R IN TERFA CES
Barcode Generator In None
Using Barcode creation for Online Control to generate, create Barcode image in Online applications.
www.OnBarcode.com
Barcode Reader In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Listing 11-29. A Generic, Highlightable List Box Item using using using using using System; Microsoft.SPOT; Microsoft.SPOT.Presentation.Controls; Microsoft.SPOT.Presentation.Media; Microsoft.SPOT.Presentation;
Barcode Reader In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Data Matrix 2d Barcode Recognizer In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
namespace Kuehner.SPOT.Presentation.Controls { public class HighlightableListBoxItem : ListBoxItem { public HighlightableListBoxItem() { this.Background = null; } public HighlightableListBoxItem(UIElement content) { this.Child = content; this.Background = null; } protected override void OnIsSelectedChanged(bool isSelected) { if (isSelected) { Color selectionColor = ColorUtility.ColorFromRGB(0x00, 0x94, 0xFF); this.Background = new SolidColorBrush(selectionColor); } else this.Background = null; } } } We can add further improvements. First, it looks nicer to separate the list box items a little bit. To do so, you need to add a margin to the enclosed text content. Do not add the margin to the outer, parent list box item, because that would display a small, highlighted background. Another improvement is to change the text color to white when an item is highlighted. Because displaying a list box with text items is a common scenario, it is a good idea to derive a custom HighLightableTextListBoxItem to do all this for us (see Listing 11-30).
Draw Barcode In Objective-C
Using Barcode generation for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Draw QR Code In None
Using Barcode encoder for Online Control to generate, create QR Code image in Online applications.
www.OnBarcode.com
CHAPTER 11 GRA PHICS AN D G RAPHIC AL US ER INTERFA CES
DataMatrix Creation In .NET
Using Barcode maker for Reporting Service Control to generate, create ECC200 image in Reporting Service applications.
www.OnBarcode.com
PDF417 Generator In None
Using Barcode printer for Software Control to generate, create PDF 417 image in Software applications.
www.OnBarcode.com
Listing 11-30. The HighlightableTextListBoxItem using using using using using System; Microsoft.SPOT; Microsoft.SPOT.Presentation.Controls; Microsoft.SPOT.Presentation.Media; Microsoft.SPOT.Presentation;
Create Quick Response Code In Java
Using Barcode encoder for Java Control to generate, create QR-Code image in Java applications.
www.OnBarcode.com
Barcode Reader In .NET
Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications.
www.OnBarcode.com
namespace Kuehner.SPOT.Presentation.Controls { public class HighlightableTextListBoxItem : HighlightableListBoxItem { private readonly Text text; public HighlightableTextListBoxItem(Font font, string content) : base() { // create and remember a text element from the given // font and text content this.text = new Text(font, content); this.text.SetMargin(2); // set the margin for the text this.Child = this.text; // add as child content } protected override void OnIsSelectedChanged(bool isSelected) { if (isSelected) { Color selectionColor = ColorUtility.ColorFromRGB(0x00, 0x94, 0xFF); this.Background = new SolidColorBrush(selectionColor); this.text.ForeColor = Color.White; } else { this.Background = null; this.text.ForeColor = Color.Black; } } } } Now you have a reusable text list box item that creates a nice looking text list box (see Figure 11-40).
C HAPT ER 11 GRAPHICS AND GRA PHICA L USE R IN TERFA CES
Figure 11-40. Using HighlightableTextListBoxItem
Displaying Separator Items
You might want to group your items into lists that are divided with a separator (see Figure 11-41). A separator is a list box item that cannot be selected. The ListBoxItem class provides the IsSelectable property to configure whether or not an item can be selected. You can easily add a separator by adding a Rectangle shape with a height of 1 pixel to a list box item. You should add a margin to either the rectangle shape or list box item. In this case, it does not matter which, because the item will not be selectable and will never be highlighted. You should gray out the separator to indicate that is not selectable. It is a good idea to pack all this in a custom list box item called SeparatorListBoxItem (see Listing 11-31) to have a reusable component. Listing 11-31. A Reusable Separator List Box Item using using using using using System; Microsoft.SPOT; Microsoft.SPOT.Presentation.Controls; Microsoft.SPOT.Presentation.Shapes; Microsoft.SPOT.Presentation.Media;
namespace Kuehner.SPOT.Presentation.Controls { public class SeparatorListBoxItem : ListBoxItem { public SeparatorListBoxItem() { Rectangle rect = new Rectangle(); rect.Height = 1; rect.Stroke = new Pen(Colors.Gray); this.Child = rect; this.IsSelectable = false; this.SetMargin(2); } } }
Copyright © OnBarcode.com . All rights reserved.