Text Boxes in C++
-
Hi all, I am new to C++ and I want to get the value from a text box merge it with another string and then re-populate the text box. I am using the text box in a windows form. Here is the code I have tried but doesn't work string S1; S1 = this->textBox1->Text; textBox1->Text = S1 + "Test1"; Thanks Ben
-
Hi all, I am new to C++ and I want to get the value from a text box merge it with another string and then re-populate the text box. I am using the text box in a windows form. Here is the code I have tried but doesn't work string S1; S1 = this->textBox1->Text; textBox1->Text = S1 + "Test1"; Thanks Ben
You would be having some control for the text box. If not go to class wizard and create it. Let us name it as tb.Now you can access the text box text by calling GetWindowText. Modify the string and use SetWindowText to set the text back to the text box Regards Anshuman
-
Hi all, I am new to C++ and I want to get the value from a text box merge it with another string and then re-populate the text box. I am using the text box in a windows form. Here is the code I have tried but doesn't work string S1; S1 = this->textBox1->Text; textBox1->Text = S1 + "Test1"; Thanks Ben
For this you have to use SetWindowText() and GetWindowText().
BOOL SetWindowText(
HWND hWnd,
LPCTSTR lpString
);int GetWindowText(
HWND hWnd,
LPTSTR lpString,
int nMaxCount
);TCHAR lpString[100];
GetWindowText(hEdit, lpString, sizeof(lpstring))
_tcscat(lpString, " another string");SetWindowText(hEdit, lpString)
Now this will work.:)Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
-
For this you have to use SetWindowText() and GetWindowText().
BOOL SetWindowText(
HWND hWnd,
LPCTSTR lpString
);int GetWindowText(
HWND hWnd,
LPTSTR lpString,
int nMaxCount
);TCHAR lpString[100];
GetWindowText(hEdit, lpString, sizeof(lpstring))
_tcscat(lpString, " another string");SetWindowText(hEdit, lpString)
Now this will work.:)Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
prefer the
GetWindowText()
andSetWindowText()
that handlesCString
s :CString strMsg = " World";
CString strEditContent; //let's say "Hello"//gets the edit handle
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_MY_EDIT);//gets the edit string
pEdit->GetWindowText(strEditContent);//concatenate the strings
strEditContent += strMsg;//sets the edit string
pEdit->SetWindowText(strEditContent);
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -- modified at 7:18 Monday 16th January, 2006 -
prefer the
GetWindowText()
andSetWindowText()
that handlesCString
s :CString strMsg = " World";
CString strEditContent; //let's say "Hello"//gets the edit handle
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_MY_EDIT);//gets the edit string
pEdit->GetWindowText(strEditContent);//concatenate the strings
strEditContent += strMsg;//sets the edit string
pEdit->SetWindowText(strEditContent);
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -- modified at 7:18 Monday 16th January, 2006Hmmm, you are right. But seeing his post I thought he must be using SDK.
Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
-
Hi all, I am new to C++ and I want to get the value from a text box merge it with another string and then re-populate the text box. I am using the text box in a windows form. Here is the code I have tried but doesn't work string S1; S1 = this->textBox1->Text; textBox1->Text = S1 + "Test1"; Thanks Ben
Gktony wrote:
string S1; S1 = this->textBox1->Text; textBox1->Text = S1 + "Test1";
this is certainly a VB++!! :)
0x0400: "But your mind is very complex, very tricky. It makes simple things complicated. -- that's its work. And for centuries it has been trained for only one thing: to make things so complicated that your life becomes impossible."- Osho
--[V]--
-
Hi all, I am new to C++ and I want to get the value from a text box merge it with another string and then re-populate the text box. I am using the text box in a windows form. Here is the code I have tried but doesn't work string S1; S1 = this->textBox1->Text; textBox1->Text = S1 + "Test1"; Thanks Ben
Thank you all for your replies. I see you are using SetWindowText() and GetWindowText(). In the meantime I have tried the following and it worked. String* S1 = textBox1->Text; textBox1->Text = String::Concat(S1, S"Test"); Am I not suppose to code like that in C++ as there are better way of doing it? Thanks Ben
-
Thank you all for your replies. I see you are using SetWindowText() and GetWindowText(). In the meantime I have tried the following and it worked. String* S1 = textBox1->Text; textBox1->Text = String::Concat(S1, S"Test"); Am I not suppose to code like that in C++ as there are better way of doing it? Thanks Ben
it seems that there had a misunderstood. you are coding for .NET framework (so your question should be asked in the C++/CLI forum). our answer were in fact for Win32 / MFC... so don't take them in account.
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0]