×¢²á | µÇ¼ Íü¼ÇÃÜÂ룿 51ctoÊ×Ò³ | ²©¿Í | ÂÛ̳ | ÕÐÆ¸
ÈȵãÎÄÕ CCNA½Ì²ÄÍÆ¼ö
¡¡°ïÖú

À©Õ¹GridView¿Ø¼þ£¨¾Å£©¡ª¡ª¸øÊý¾ÝÐÐÔö¼ÓÓÒ¼ü²Ëµ¥


2007-12-11 17:21:15
½éÉÜ
¸øGridViewµÄÊý¾ÝÐÐÔö¼ÓÓÒ¼ü²Ëµ¥¿ÉÒÔÔö¼ÓÓû§ÌåÑ飬²»¹ýʵÏÖÆðÀ´Í¦Âé·³µÄ£¬ÏÖÔÚÎÒÃÇÀ©Õ¹Ò»ÏÂGridView¿Ø¼þÒÔʵÏÖÕâÑùµÄ¹¦ÄÜ¡£


¿Ø¼þ¿ª·¢
1¡¢Ð½¨Ò»¸ö¼Ì³Ð×ÔGridViewµÄÀà¡£
/// <summary>
/// ¼Ì³Ð×ÔGridView
/// </summary>

[ToolboxData(@"<{0}:SmartGridView runat='server'></{0}:SmartGridView>")]
public class SmartGridView : GridView
{
}

2¡¢Ð½¨Ò»¸öContextMenuʵÌåÀ࣬ÓÐÁù¸öÊôÐÔ
using System;
using System.Collections.Generic;
using System.Text;

using System.ComponentModel;
using System.Web.UI;

namespace YYControls.SmartGridView
{
    
/// <summary>
    
/// ContextMenu µÄժҪ˵Ã÷¡£
    
/// </summary>

    [ToolboxItem(false)]
    
public class ContextMenu
    
{
        
private string _icon;
        
/// <summary>
        
/// ÎÄ×Ö×ó±ßµÄͼ±êµÄÁ´½Ó
        
/// </summary>

        public string Icon
        
{
            
get return _icon; }
            
set { _icon = value; }
        }


        
private string _text;
        
/// <summary>
        
/// ²Ëµ¥µÄÎÄ×Ö
        
/// </summary>

        public string Text
        
{
            
get return _text; }
            
set { _text = value; }
        }

       
        
private string _commandButtonId;
        
/// <summary>
        
/// Ëùµ÷ÓõÄÃüÁî°´Å¥µÄID
        
/// </summary>

        public string CommandButtonId
        
{
            
get return _commandButtonId; }
            
set { _commandButtonId = value; }
        }


        
private string _navigateUrl;
        
/// <summary>
        
/// Á´½ÓµÄurl
        
/// </summary>

        public string NavigateUrl
        
{
            
get return _navigateUrl; }
            
set { _navigateUrl = value; }
        }


        
private ItemTypeCollection _itemType;
        
/// <summary>
        
/// ÓÒ¼ü²Ëµ¥µÄÏîµÄÀà±ð
        
/// </summary>

        public ItemTypeCollection ItemType
        
{
            
get return _itemType; }
            
set { _itemType = value; }
        }


        
private TargetCollection _target;
        
/// <summary>
        
/// Á´½ÓµÄtarget
        
/// </summary>

        public TargetCollection Target
        
{
            
get return _target; }
            
set { _target = value; }
        }



        
/// <summary>
        
/// ÓÒ¼ü²Ëµ¥µÄÏîµÄÀà±ð
        
/// </summary>

        public enum ItemTypeCollection
        
{
            
/// <summary>
            
/// Á´½Ó
            
/// </summary>

            Link,
            
/// <summary>
            
/// °´Å¥
            
/// </summary>

            Command,
            
/// <summary>
            
/// ·Ö¸ôÏß
            
/// </summary>

            Separator
        }


        
/// <summary>
        
/// Á´½ÓµÄtarget
        
/// </summary>

        public enum TargetCollection
        
{
            
/// <summary>
            
/// Ð¿ª´°¿Ú
            
/// </summary>

            Blank,
            
/// <summary>
            
/// µ±Ç°´°¿Ú
            
/// </summary>

            Self,
            
/// <summary>
            
/// Ìø³ö¿ò¼Ü
            
/// </summary>

            Top
        }

    }

}


3¡¢Ð½¨Ò»¸ö¼Ì³Ð×ÔCollectionBaseµÄÀàContextMenus
using System.Collections;
using System.ComponentModel;
using System.Web.UI;

namespace YYControls.SmartGridView
{
    
/// <summary>
    
/// ContextMenus µÄժҪ˵Ã÷¡£
    
/// ×¢ÒâÒª¼Ì³Ð×ÔCollectionBase
    
/// </summary>

    [
    ToolboxItem(
false),
    ParseChildren(
true)
    ]
    
public class ContextMenus : CollectionBase
    
{
        
/// <summary>
        
/// ¹¹Ô캯Êý
        
/// </summary>

        public ContextMenus()
            : 
base()
        
{
        }


        
/// <summary>
        
/// ÊµÏÖIList½Ó¿Ú
        
/// »ñÈ¡»òÉèÖÃÖ¸¶¨Ë÷Òý´¦µÄÔªËØ¡£
        
/// </summary>
        
/// <param name="index">Òª»ñµÃ»òÉèÖõÄÔªËØ´ÓÁ㿪ʼµÄË÷Òý</param>
        
/// <returns></returns>

        public ContextMenu this[int index]
        
{
            
get
            
{
                
return (ContextMenu)base.List[index];
            }

            
set
            
{
                
base.List[index] = (ContextMenu)value;
            }

        }


        
/// <summary>
        
/// ÊµÏÖIList½Ó¿Ú
        
/// ½«Ä³ÏîÌí¼Óµ½ System.Collections.IList ÖС£
        
/// </summary>
        
/// <param name="item">ÒªÌí¼Óµ½ System.Collections.IList µÄ System.Object¡£</param>

        public void Add(ContextMenu item)
        
{
            
base.List.Add(item);
        }


        
/// <summary>
        
/// ÊµÏÖIList½Ó¿Ú
        
/// ´Ó System.Collections.IList ÖÐÒÆ³ýÌØ¶¨¶ÔÏóµÄµÚÒ»¸öÆ¥ÅäÏî¡£
        
/// </summary>
        
/// <param name="index">Ò