zoukankan      html  css  js  c++  java
  • 贴两段代码

    因为没有找到如何在ComboBox和ListBox中的item附加tag的办法,所以自己添加了一下。主要是试验一下如何用博客园新加的代码高亮这个酷酷的功能:

    public class FlexComboBox : System.Windows.Forms.ComboBox
        
    {
            
    private System.Collections.ArrayList ItemValues = new System.Collections.ArrayList();
            
    public void FlexAddItem(string itemText, object itemValue)
            
    {
                
    this.Items.Add(itemText);
                ItemValues.Add(itemValue);
            }

            
    public object FlexGetSelectedItemValue()
            
    {
                
    return ItemValues[this.SelectedIndex];
            }

            
    public void FlexClearItems()
            
    {
                ItemValues.Clear();
                
    this.Items.Clear();
            }

        }

    public class FlexListBox : System.Windows.Forms.ListBox
        
    {
            
    private ArrayList itemValues = new ArrayList();
            
    public FlexListBox() { }

            
    public void FlexAddItem(string itemText, object itemValue)
            
    {
                
    this.Items.Add(itemText);
                itemValues.Add(itemValue);
            }

            
    public void FlexRemoveSelectedItems()
            
    {
                
    for(int i=0;i<this.SelectedIndices.Count;i++)
                
    {
                    
    int index = this.SelectedIndices[i];
                    
    this.Items.RemoveAt(index);
                    itemValues.RemoveAt(index);
                }

            }

            
    public void FlexClearItems()
            
    {
                itemValues.Clear();
                
    this.Items.Clear();
            }

            
    public ArrayList FlexGetItemValues()
            
    {
                
    return itemValues;
            }

            
    public object FlexGetSelectedValue()
            
    {
                
    return itemValues[this.SelectedIndex];
            }

        }
  • 相关阅读:
    final/override控制
    高效遍历图像
    快速初始化成员变量
    C++ boost.python折腾笔记
    百亿数据毫秒响应级交易系统读写分离存储数据设计
    解决VS2010子目录中的.cpp文件引用上一级目录的stdafx.h找不到定义的问题
    生产应用常见坑
    spring AOP应用
    springmvc No mapping found for HTTP request with URI in Dispatc
    myeclipse使用maven插件进行maven install时报错check $m2_home environment variable and mvn script match
  • 原文地址:https://www.cnblogs.com/taowen/p/21165.html
Copyright © 2011-2022 走看看