Tuesday, July 15, 2008

How to find string within ComboBox in .NET CF

Hi
The comapct framework haven't method for find a string within combobox, but native code have support. So little P/Invoke and get tht features to .NET CF

Here code for you.

public const int CB_FINDSTRINGEXACT = 0x0158;

[DllImport("coredll.dll")]
internal static extern int SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);

private void FindStringExact(string find)
{
int m = SendMessage(comboBox1.Handle, CB_FINDSTRINGEXACT, 0, find + "\0");
if (m > 0)
{
MessageBox.Show(find);
}
else
{
MessageBox.Show("no");
}
}


Thank you

No comments: