Click here to Skip to main content
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 OriginalGriff 625
1 CPallini 320
2 Sergey Alexandrovich Kryukov 305
3 BillWoodruff 269
4 Peter Leow 255


Advertise | Privacy | Mobile
Web04 | 2.8.141029.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
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