Monday, January 23, 2006

VS 2005 & VB.NET Combobox readonly

I have a combobox in VS2005 that is read only when compiled for Pocket PC. The same code in VB for the desktop creates a combobox in which the user can type some free text (wierd?). Although the changes aren't saved as any of the choices, this is still no good as it gives the user the impression that the value he/she typed in is the value that is being processed by the program when the submit/enter button is clicked on my app to produce a calculation.



After searching forever, I found someone who posted an elegant solution:



[vb.net]
Private Sub comboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cmbTipo.KeyPress
e.Handled = True
End Sub



http://www.codeproject.com/cs/miscctrl/ReadOnlyComboBox.asp#xx1093207xx

No comments:

Post a Comment