Click here to Skip to main content
15,894,330 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Hello There

I have a problem with DataGridViewComboBoxColumn. I got the solution for it but the code is in VB. I tried to convert it into c# but still not find exact syntax.
Code is:-
VB
If TypeOf e.Control Is ComboBox Then
Dim cbo As ComboBox = DirectCast(e.Control, ComboBox)
cbo.DropDownHeight = 250
End If


Want to convert it into c#.

Need Suggestion
Best Regards
Posted

try this:-

C#
if (e.Control is ComboBox) {
    ComboBox cbo = (ComboBox)e.Control;
    cbo.DropDownHeight = 250;
}
 
Share this answer
 
v2
Comments
Joezer BH 5-Aug-13 5:26am    
5ed!
Try that snippet:
C#
ComboBox cbo = e.Control as ComboBox;
if(cbo != null)
{
    cbo.DropDownHeight = 250;
}
 
Share this answer
 
Comments
Joezer BH 5-Aug-13 5:26am    
5ed!
Try this:
C#
if (e.Control is ComboBox)
    (ComboBox)e.Control.DropDownHeight = 250;
 
Share this answer
 
v2
Comments
ridoy 5-Aug-13 5:38am    
my 5!
Joezer BH 5-Aug-13 8:28am    
Thank you ridoy
C#
if (e.Control is ComboBox) {
    ComboBox cbo = (ComboBox)e.Control;
    cbo.DropDownHeight = 250;
}


Generated using this link:
VB.Net to C# Converter[^]
 
Share this answer
 
Comments
Joezer BH 5-Aug-13 5:25am    
5ed!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900