I agree, why not use Lines[] instead?
| |
// Get the first line of multi-line textBox1 string line1 = textBox1.Lines[0]; MessageBox.Show(line1);
|
It's easier that way. But if you insists on using API to send EM_GETLINE message to your multi-line textbox, then you need to modify your API declaration for
SendMessage API and make its lParam as
StringBuilder type, like this:
| |
[DllImport("user32.dll", EntryPoint="SendMessageA")] private static extern int SendMessage_Ex (IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam); private const int EM_GETLINE = 0xc4;
|
Then call it this way:
| |
StringBuilder buffer = new StringBuilder(256); SendMessage_Ex(textBox1.Handle, EM_GETLINE, 0, buffer); MessageBox.Show(buffer.ToString());
|
Hope this helps,
-chris