Juni 2010Juni 2010

Rabu, 30 Juni 2010

Procedure untuk mengambil karakter dari kiri,kanan atau tengah pada c#


Procedure untuk mengambil karakter dari kiri,kanan atau tengah


public static string Kiri(string param, int length) //fungsi untuk mengambil
//karakter dari sebelah kiri
{
string result = param.Substring(0,length);
return result;
}
public static string Kanan(string param, int length) //fungsi untuk mengambil
//karakter dari sebelah kanan
{
string result = param.Substring(param.Length - length, length);
return result;
}
public static string tengah(string param,int start, int length) //fungsi untuk mengambil
//karakter dari sebelah kiri
{
string result = param.Substring(start, length);
return result;
}


Selengkapnya...

ListViewItem Collection Editor



When you select the first item on the ListView Tasks menu, the ListViewItem Collection Editor is displayed. This editor can also be accessed by clicking on the button in the right hand column of the Items property in the Properties Window.


Once the editor is open, ListViewItems can be added or removed, and their properties can be set. A ListViewItem object can display an image along with text. An ImageList must be used to associate an image with a ListViewItem object.
The ListViewItem class represents items in a ListView control and the ListViewSubItem class represents a sub-item related to a ListViewItem. The ListViewItem class exposes the SubItems collection property that represents the list of sub-items related to an item. The number of sub-items should equal the number of columns minus one.
This editor can also be accessed by clicking on the button in the right hand column of the SubItems property in the ListViewItem Collection Editor.

Adding items manually
Items can be added manually by adding ListViewItems to the ListView's Items collection property. The following code demonstrates how to add items to a ListView control:


ListViewItem listViewItem1 = new ListViewItem();
ListViewSubItem listViewSubItem1 = new ListViewSubItem();

listViewItem1.Text = "Joe";
listViewSubItem1.Text = "123 Somewhere Street";

listViewItem1.SubItems.Add(listViewSubItem1);
listView1.Items.Add(listViewItem1);



source : http://en.csharp-online.net/ListView
Selengkapnya...

ListView Tasks



When you select the ListView and click on the Smart Tag icon , a small menu appears with the list of tasks that can be achieved through it.


The top-most task allows you to Edit Items, which is a collection containing all of the ListViewItems in the control. The ListViewItem class defines the appearance, behavior, and data associated with an item that is displayed in the ListView control.
You can set the images associated with a particular ListViewItem by setting either the ImageIndex or ImageKey property of each ListViewItem. The View property determines if the ListView items are shown with large images, small images, or in a view that exposes the sub-items of the ListViewItems.
Selengkapnya...

using list view in c#



A ListView control allows you to display a list of items with an optional icon in a similar manner to Windows Explorer. The most often used manner is to show a multicolumn list of items as displayed here.


However, the ListView control supports five distinct modes of viewing, very similar in nature to those that can be achieved using Windows Explorer. This is done through the View property.

Useful properties

  • Activation - Defines the type of action the user must take to activate an item. Takes a value from the ItemActivation enumeration:
OneClick - The user must single-click to activate items. The cursor changes to a hand pointer cursor, and the item text changes colour as the user moves the mouse pointer over the item.
Standard - The user must double-click to activate items. No feedback is given as the user moves the mouse pointer over an item. (default value)
TwoClick - The user must click an item twice to activate it. This is different from the standard double-click because the two clicks can have any duration between them. The item text changes colour as the user moves the mouse pointer over the item.

  • Alignment - Defines the alignment of items in the control when the View property is set to LargeIcon or SmallIcon. Takes a value from the ListViewAlignment enumeration:
Default - When the user moves an item, it remains where it is dropped.
Left - Items are aligned to the left of the ListView control.
SnapToGrid - Items are aligned to an invisible grid in the control. When the user moves an item, it moves to the closest juncture in the grid.
Top - Items are aligned to the top of the ListView control. (Default setting)

  • AllowColumnReorder - Indicates whether the user can drag column headers to reorder columns in the control at run time when the View property is set to Details.
  • AutoArrange - Determines whether icons are automatically kept arranged and snapped to the grid when the View property is set to LargeIcon or SmallIcon.
  • CheckBoxes - Indicates whether a check box appears next to each item in the control.
  • CheckedIndices - Gets the indexes of the currently checked items in the control.
  • CheckedItems - Gets the currently checked items in the control.
  • Columns - Gets the collection of all column headers that appear in the control when the View property is set to Details.

Note:
If your ListView control does not have any column headers specified and you set the View property to Details, the ListView control will not display any items.

  • ContextMenuStrip - Defines the ContextMenuStrip associated with this control.
  • FullRowSelect - Indicates whether clicking an item selects all its sub-items when the View property is set to Details.
  • Groups - Gets the collection of ListViewGroup objects assigned to the control. The ListView grouping feature lets you create visual groups of logically related ListView items. Each group consists of a textual header followed by a horizontal line and the items assigned to that group.
  • HeaderStyle - Specifies the type of column headers to display when the View property of the ListView control is set to Details and the ListView control has ColumnHeader objects specified in the ListView.ColumnHeaderCollection. Takes a value from the ColumnHeaderStyle enumeration
  • HideSelection - Indicates whether the selected item in the control remains highlighted when the control loses focus.
  • HotTracking - Indicates whether the text of an item or sub-item has the appearance of a hyperlink when the mouse pointer passes over it.
Note:
Enabling hot tracking will cause the Activation property to be set to OneClick and the HoverSelection property to be set to true. In addition, run-time label editing is not allowed when hot tracking is enabled.

  • HoverSelection - Indicates whether an item is automatically selected when the mouse pointer remains over the item for a few seconds. When this property is set to true, the user can point to an item in the ListView control to select the item. Multiple items can be selected (when the MultiSelect property is set to true) by holding down the control key while pointing to each item.
  • InsertionMark - Gets a ListViewInsertionMark object used to indicate the expected drop location when an item is dragged within a ListView control. This lets you visually indicate the expected drop location in a drag-and-drop operation when an item is dragged to a new position. This feature works only when the AutoArrange property is set to true and when the ListView control does not sort the items automatically.
  • Items - Gets a collection containing all of the ListViewItems in the control.
  • LabelEdit - Indicates whether the user can edit the labels of items in the control. When set to true, the user is able to modify the text of an item. If the Activation property is set to OneClick or TwoClick, label editing will not be allowed.
  • LabelWrap - Indicates whether item labels wrap when items are displayed in the control as icons.
  • LargeImageList - Defines the ImageList to use when displaying items as large icons in the control.
  • MultiSelect - Indicates whether multiple items can be selected.
  • Scrollable - Indicates whether a scroll bar is added to the control when there is not enough room to display all items.
  • SelectedIndices - Gets the indexes of the selected items in the control.
  • SelectedItems - Gets the items that are selected in the control.
  • ShowGroups - Indicates whether items are displayed in groups.
  • ShowItemToolTips - Indicates whether ToolTips are shown for the ListViewItem objects contained in the ListView.
  • TileSize - Defines the size of the tiles shown in tile view.
  • TopItem - Defines the first visible item in the control.
  • View - Defines how items are displayed in the control. Takes a value from the View enumeration:
  1. Details - Each item appears on a separate line with further information about each item arranged in columns. The left-most column contains a small icon and label, and subsequent columns contain sub items as specified by the application. A column displays a header which can display a caption for the column. The user can resize each column at run time.
  2. LargeIcon - Each item appears as a full-sized icon with a label below it.
  3. List - Each item appears as a small icon with a label to its right. Items are arranged in columns with no column headers.
  4. SmallIcon - Each item appears as a small icon with a label to its right.
  5. Tile - Each item appears as a full-sized icon with the item label and subitem information to the right of it. The subitem information that appears is specified by the application. This view is available only on Windows XP and the Windows Server 2003 family. On earlier operating systems, this value is ignored and the ListView control displays in the LargeIcon view.

source : http://en.csharp-online.net/ListView
Selengkapnya...