Click here to Skip to main content
11,641,659 members (62,237 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm
hi
i have a DataTreeListView.I want to edit items. In editing on of the cells should cast to ComboBox.

when i write
private void dataTreeListView1_CellEditStarting(object sender, CellEditEventArgs e)
        {
ComboBox responsiblePersonNameCombo = (ComboBox)e.Control;
 
}
vs got error:
casting TextBox to ComboBox is invalid!

i dont know what to do!
Posted 6-Jan-13 2:51am
Edited 6-Jan-13 2:55am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

casting TextBox to ComboBox is invalid!
Error is quite straight forward and self explanatory.
e.Control is of datatype Textbox and thus when you try to cast into Combobox, you get the error.
  Permalink  
Comments
Espen Harlinn at 6-Jan-13 9:22am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Simply try to change Dropdown behavior of your dropdown :
private void dataTreeListView1_CellEditStarting(object sender, CellEditEventArgs e)
{
    comboBox1.DropDownStyle = ComboBoxStyle.Simple;
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 253
1 Mika Wendelius 160
2 Sergey Alexandrovich Kryukov 134
3 OriginalGriff 110
4 Afzaal Ahmad Zeeshan 79
0 Mika Wendelius 460
1 OriginalGriff 265
2 DamithSL 258
3 CPallini 169
4 Afzaal Ahmad Zeeshan 149


Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100