Hi, I'm new at Visual C++ and I can't figure out how to change the text
property of a label. I'm using a char[] variable that I'd like to assign to
the label. Perhaps I should use a System::String^ instead? But when I try
that, I get an error that I can't use a System::String^ as a global or static
variable. What I want to be able to do is the change say the third character
of the text in the text property of the label control from, say, 'k' to 'm'.
Maybe there's a very simple way to do this. 2 2443
"Steven" <St****@discuss ions.microsoft. comwrote in message
news:DD******** *************** ***********@mic rosoft.com...
Hi, I'm new at Visual C++ and I can't figure out how to change the text
property of a label. I'm using a char[] variable that I'd like to assign
to
the label. Perhaps I should use a System::String^ instead? But when I try
that, I get an error that I can't use a System::String^ as a global or
static
variable. What I want to be able to do is the change say the third
character
of the text in the text property of the label control from, say, 'k' to
'm'.
Maybe there's a very simple way to do this.
There's a String constructor that accepts a C++ char (.NET SByte), so:
char* the_text = "Some ordinary string here."
label1->Text = gcnew String(the_text );
However, that's going to do an ASCII->Unicode conversion. You may be
happier using .NET Char (C++ wchar_t) arrays. To do that you have to write
your string literals like L"string" and character literals like L'm'.
Getting to individual (Unicode) characters of .NET Strings is easy:
interior_ptr<wc har_tunistr = PtrToStringChar s(label->Text);
To do the simple replacement you mentioned, you might do:
array<wchar_t>^ s = label->Text->ToCharArray( );
if (s[2] == L'k') s[2] == L'm';
label->Text = new String(s);
You don't say what environment you are using? Is this managed or unmanaged
code? If managed, look at Ben Voigt's reply. If not, you are dealing with
window handles. Now, are you doing raw C++, ATL, WTL, or MFC? If the former,
investigate SetWindowText(h wnd, "here is a string").
/steveA
Steven wrote:
Hi, I'm new at Visual C++ and I can't figure out how to change the text
property of a label. I'm using a char[] variable that I'd like to assign to
the label. Perhaps I should use a System::String^ instead? But when I try
that, I get an error that I can't use a System::String^ as a global or static
variable. What I want to be able to do is the change say the third character
of the text in the text property of the label control from, say, 'k' to 'm'.
Maybe there's a very simple way to do this.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Cengiz Ulku |
last post by:
Hi,
I've already posted a question similar but will need some precisions and
help.
I have a rtf file displayed within a RTB control. Above it, I have a text
box control with a scroller which helps me to increase/decrease numbers
inside it by clicking. (There should be a shorter name for this control!!!)
What I want is: Whenever I click the increase the number button, the
|
by: Eric |
last post by:
How can I dynamically assign an event to an element?
I have tried :
(myelement is a text input)
document.getElementById('myelement').onKeyUp =
"myfnc(param1,param2,param3)";
document.getElementById('myelement') = new
Function("myfnc(param1,param2,param3)");
|
by: Mark Kurten |
last post by:
i have the code below:
for starters the value of txtempid = 1
after i go through this routine (i put a break point on the txtname.value
line), the value of txtEmpID is 2 (Just like it is suppose to be)
However, when i come into this function again, txtEmpID = 1 again
For some reason the txtEmpID.value isn't retaining its actual value of 2
any ideas?
Try
|
by: Abhishek Srivastava |
last post by:
Hello All,
I have bound an ArrayList to a repeater control. When the list is
displayed, I want the the user to be able to choose one of the items in
the list and then continue working. To achieve this I have done the
following
<asp:Repeater id='rep1' runat='server'>
<HeaderTemplate>
<table>
|
by: Leor Amikam |
last post by:
I want to use a css element and apply it to all labels on a page with the
"asp:label" tag.
I defined a CSS class:
..cls1
{
font-weight: bold;
color: royalblue;
font-family: Verdana;
| |
by: JJ_377 |
last post by:
The following doesn't assign value to the dropdownlist - WHY?
___________________________________________________________________
In a user control (ascx named USACustomer) :
Public Property State() As String
Get
Return Me.ddlState.SelectedValue
End Get
Set(ByVal Value As String)
|
by: david |
last post by:
I try to use "for" loop to retrieve and assign values in web form. The code
is in the following. But it can not be compiled.
What I want to do is:
txtQ1.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q1")
txtQ2.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q2")
.....
txtQ10.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q10")
------code -------
Dim field As String = "Q"
|
by: rachit.goyal |
last post by:
Hi All,
I am using .net first time.In my windows form VC7 application, on a
click of button, I am assigning text of TextBox to STL string varibale.
Using this code-
private: System::Void FindValuesButton_Click(System::Object * sender,
System::EventArgs * e)
{
string fileLoc ;
fileLoc= CD_location->Text->ToString();
|
by: =?Utf-8?B?U3RldmVu?= |
last post by:
Hi, I'm new at Visual C++ and I can't figure out how to change the text
property of a label. I'm using a char variable that I'd like to assign to
the label. Perhaps I should use a System::String^ instead? But when I try
that, I get an error that I can't use a System::String^ as a global or static
variable. What I want to be able to do is the change say the third character
of the text in the text property of the label control from, say,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |