C++ Standards, Extensions, and Interop


windows forms vs2010 c++


Hi
combox -
How do I define the list of possible strings in my program code ?
I need to update the list all the time.
I know to define it permanently using the designer. I also saw the "Items->AddRange( ...) ;
But I don't know how to write it in my code. I don't know CLI, I did not find explanation for it or any sample code.
I dont intend to be expert now. Just need to make a progress.
Thanks
Try this:
comboBox1->Items->Clear();
comboBox1->Items->Add("Item 1");
comboBox1->Items->Add("Item 2");
comboBox1->Items->Add("Item 3");
comboBox2->Items->Add (gcnew String(my_str1));
Incidentally, you should be using wchar_t* instead of char* throughout your code. There are very few cases nowadays in these days of UNICODE where char* is required.
Try this:
comboBox1->Items->Clear();
comboBox1->Items->Add("Item 1");
comboBox1->Items->Add("Item 2");
comboBox1->Items->Add("Item 3");
Thanks
It worked. (comboBox2->Items->Add( ("bla1) );
But it when I tried to put a non constant string - the compiler did not accept it.
char my_str1[22];
sprintf(my_str1, "%s", "nmy1");
comboBox2->Items->Add( (my_str1) );
error C2664: 'System::Windows::Forms::ComboBox::ObjectCollection::Add' : cannot convert parameter 1 from 'char [22]' to 'System::Object ^'
1> Reason: cannot convert from 'char *' to 'System::Object ^'
1> No user-defined-conversion operator available, or
1> Cannot convert an unmanaged type to a managed type
Please help
comboBox2->Items->Add (gcnew String(my_str1));
Incidentally, you should be using wchar_t* instead of char* throughout your code. There are very few cases nowadays in these days of UNICODE where char* is required.
Try this example:
String ^ s = "One";
int i = 1956;
comboBox2->Items->Add(String::Format("Item {0} - {1}", s, i));
Well , It worked fine. I compiled it and run it.
But when I went to the designer view It got stuck
and I got this error messages report.
So I cannot continue ...
Maybe the designer wizard has a problem with the gcnew , that I added ?
help
To prevent possible data loss before loading the designer, the following errors must be resolved:
1 Error
Ignore and Continue
Why am I seeing this page?
C++ CodeDOM parser error: Line: 350, Column: 21 --- Internal Error
Instances of this error (1)
1.
Show Call Stack
at Microsoft.VisualC.CppCodeParser.OnMethodPopulateStatements(Object sender, EventArgs e)
at System.CodeDom.CodeMemberMethod.get_Statements()
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
Help with this error
Could not find an associated help topic for this error.
Check Windows Forms Design-Time error list
Forum posts about this error
Search the MSDN Forums for posts related to this error
Now I also tried to change my char to wchar_t
It did not help ...
It worked the same but I could not go back to the designer view

Related Links

what is the double colon when using structures?
how to get IE Browser Handler(hwnd)
ActiveX Deployment: VC 2005 Redistributable Issues
LNK2001 ?
AFX_MANAGE_STATE() macro disturbs the startup position of the ATL dialog
how to change the "Language support for non-Unicode language" in VC
STL vector sizing question
Using Direct2D how would i fill a font with a gradient or radial brush?
Beginner c++ question--Bitwise enumerations
int i = 2; Is this the Assingment Operator here ?
How do you define a template class's constructor outside the class
MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
How to use another variable from another Form in VisualC++
Accessing a member through a pointer
How to copy one char* array into another one?
definition of dllimport static data member not allowed

Categories

MSDN
Using Forums
Visual Studio Team Fou...
Microsoft Robotics
Windows Server
Archived Forums I-L
Archived Forums M
Archived Forums SA-SM
Archived Forums W
Announcements for all ...
Parallel Computing in ...
Visual Studio LightSwi...
Visual Studio Unit Tes...
Payouts and Reporting
Network Monitor
Windows Desktop SDK
Windows Desktop Ribbon...
Windows Hardware Testi...
SharePoint 2013 - Deve...
SharePoint Legacy Vers...
Azure SQL Database
Pricing & Billing
Azure Active Directory
Azure Marketplace
Azure API Management
Machine Learning
Azure Stack
Azure Analysis Services
Azure Blockchain
Azure Database for MySQL
.NET Framework Class L...
Visual Studio Visualiz...
Team Foundation Server...
BizTalk Server RFID
WCF Data Services
ADO.NET Entity Framewo...
HealthVault Developer
Visual Basic for Appli...
SyncFx – Microsoft Syn...
SQL Server Analysis Se...
SQL Server Spatial
Standard 7: Misc
MSDN and TechNet Searc...
WebsitePanel - Support
Known Issues for Windo...
Windows Protocols
Office Protocols
Silverlight Installati...
Getting Started with S...
Hosting and Streaming ...
Silverlight 4
Accessing Web Services...
PivotViewer Control wi...
Expression Blend + Ske...
Microsoft Security Dev...
Project Standard and P...
.NET StockTrader Sampl...
Architecture, Tools, a...
Azure Startups
App Producer (archived)
Building Windows Store...
General Troubleshootin...
HD DVD Interactivity A...
ISV Community Days
Microsoft Security Dev...
Multimap API Developme...
Network Class Library ...
patterns & practices: ...
Popfly Bugs and Sugges...
Parallel Programming w...
Search Server: Known B...
Search Server: Report ...
Service Bus EAI & EDI ...
SQL Server 2014 SQL To...
SQL Server 2014 Data Q...
SQL Server 2014 In Azu...
SQL Server 2014 Analys...
Team Foundation Server...
Using Visual Round Tri...
Tailoring your Windows...
Visual C# Language
Visual Studio Performa...
Windows CardSpace ('In...
Windows Live Data Deve...
Windows Live Search: D...
Windows MultiPoint Mou...
Windows MultiPoint Mou...
Windows Phone push not...
Windows Phone Preview ...
.NET Native Preview
SQL Server 2016 Preview

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile