using System.Runtime.InteropServices;
 
 
 [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]              
        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
        const uint EM_GETLINECOUNT = 0xBA;                                                   
        IntPtr wp = IntPtr.Zero;                                                             
        IntPtr lp = IntPtr.Zero;                                                           
 
 
        private void btnkhat_Click(object sender, EventArgs e)
        {
            IntPtr khat= SendMessage(txtkhat.Handle, EM_GETLINECOUNT, wp, lp);
            MessageBox.Show(khat.ToInt32().ToString());
        }