Пример #1
0
 /// <summary>
 /// Method called when cell begins to be edited</summary>
 /// <param name="e">ListView cell cancel event args</param>
 protected void OnCellBeginEdit(ListViewCellCancelEventArgs e)
 {
     if (CellBeginEdit != null)
         CellBeginEdit(this, e);
 }
Пример #2
0
        private void StartCellEdit(ListViewItem item)
        {
            var eventArgs = new ListViewCellCancelEventArgs(m_currentRow, m_currentCol);
            OnCellBeginEdit(eventArgs);
            if (eventArgs.Cancel)
                return;

            Rectangle itemBound = item.GetBounds(ItemBoundsPortion.Entire);
            int cellLeft = itemBound.Left;
            for (int i = 0; i < m_currentCol; ++i)
                cellLeft += Columns[i].Width;

            int cellWidth = Columns[m_currentCol].Width;
            if (m_currentCol == 0 && CheckBoxes)
            {
                cellLeft += CheckBoxWidth ;
                cellWidth -= CheckBoxWidth;
            }
            cellLeft += TextOffset;
            cellWidth -=TextOffset;

            Rectangle cellBound = new Rectangle(cellLeft, itemBound.Y, cellWidth, itemBound.Height);
            if (m_propertyDescriptors[m_currentCol].PropertyType.IsEnum)
            {
                m_comboBox.DataSource = Enum.GetValues(m_propertyDescriptors[m_currentCol].PropertyType);
                m_comboBox.Bounds = cellBound;
                m_activeEditingControl = m_comboBox;
               
            }
            else
            {
                m_textBox.Bounds = cellBound;
                m_activeEditingControl = m_textBox;              
            }
            EnableEditingControl();
        }