当前位置: 首页>>代码示例>>C#>>正文


C# NSOutlineView.RowForItem方法代码示例

本文整理汇总了C#中NSOutlineView.RowForItem方法的典型用法代码示例。如果您正苦于以下问题:C# NSOutlineView.RowForItem方法的具体用法?C# NSOutlineView.RowForItem怎么用?C# NSOutlineView.RowForItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NSOutlineView的用法示例。


在下文中一共展示了NSOutlineView.RowForItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetView

		public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) {
			// Cast item
			var product = item as Product;

			// This pattern allows you reuse existing views when they are no-longer in use.
			// If the returned view is null, you instance up a new view
			// If a non-null view is returned, you modify it enough to reflect the new data
			NSTableCellView view = (NSTableCellView)outlineView.MakeView (tableColumn.Title, this);
			if (view == null) {
				view = new NSTableCellView ();
				if (tableColumn.Title == "Product") {
					view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16));
					view.AddSubview (view.ImageView);
					view.TextField = new NSTextField (new CGRect (20, 0, 400, 16));
				} else {
					view.TextField = new NSTextField (new CGRect (0, 0, 400, 16));
				}
				view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
				view.AddSubview (view.TextField);
				view.Identifier = tableColumn.Title;
				view.TextField.BackgroundColor = NSColor.Clear;
				view.TextField.Bordered = false;
				view.TextField.Selectable = false;
				view.TextField.Editable = !product.IsProductGroup;
			}

			// Tag view
			view.TextField.Tag = outlineView.RowForItem (item);

			// Allow for edit
			view.TextField.EditingEnded += (sender, e) => {

				// Grab product
				var prod = outlineView.ItemAtRow(view.Tag) as Product;

				// Take action based on type
				switch(view.Identifier) {
				case "Product":
					prod.Title = view.TextField.StringValue;
					break;
				case "Details":
					prod.Description = view.TextField.StringValue;
					break; 
				}
			};

			// Setup view based on the column selected
			switch (tableColumn.Title) {
			case "Product":
				view.ImageView.Image = NSImage.ImageNamed (product.IsProductGroup ? "tags.png" : "tag.png");
				view.TextField.StringValue = product.Title;
				break;
			case "Details":
				view.TextField.StringValue = product.Description;
				break;
			}

			return view;
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:59,代码来源:ProductOutlineDelegate.cs

示例2: GetCell

		/// <summary>
		/// Gets the cell.
		/// </summary>
		/// <returns>The cell.</returns>
		/// <param name="outlineView">Outline view.</param>
		/// <param name="tableColumn">Table column.</param>
		/// <param name="item">Item.</param>
		public override NSCell GetCell (NSOutlineView outlineView, NSTableColumn tableColumn, Foundation.NSObject item)
		{
			nint row = outlineView.RowForItem (item);
			return tableColumn.DataCellForRow (row);
		}
开发者ID:pbbpage,项目名称:mac-samples,代码行数:12,代码来源:SourceListDelegate.cs


注:本文中的NSOutlineView.RowForItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。