I want to add values to combobox in C++ builder 6.
I know I can add string to combobox by string list editor.
For example, I have added this list to combobox:
car
ball
apple
bird
I want behind each text, it has their own value, so I can get the value rahter than the text when user selected a text. Just like HTML select.
But when I try to add value to each text:
ComboBox1->Items->Values[0] = "mycar";
ComboBox1->Items->Values[1] = "aball";
etc...
it will add more text to the list, like
car
ball
apple
bird
0=mycar
1=aball
This is not what I want. I don't want the extra text to add to the list.
So, how can I add values to each text properly, and get the value?
If you want to store the values in the ComboBox itself, then you need to use the Objects[] property instead of the Values[] property, for example:
ComboBox1->Items->Objects[0] = (TObject*) new String("mycar");
ComboBox1->Items->Objects[1] = (TObject*) new String("aball");
...
String value = * (String*) ComboBox1->Items->Objects[ComboBox1->ItemIndex];
...
delete (String*) ComboBox1->Items->Objects[0];
delete (String*) ComboBox1->Items->Objects[1];
As you can see, this requires managing dynamically allocated String objects. A better option would be to store the values in a separate list, such as a TStringList or std::vector, like PoweRoy suggested. As long as that list has the same number of items as the ComboBox, you can use ComboBox indexes to access the values, for example:
TStringList *MyValues = new TStringList;
...
MyValues->Add("mycar");
MyValues->Add("aball");
...
String value = MyValues->Strings[ComboBox1->ItemIndex];
...
delete MyValues;
Or:
#include <vector>
std::vector<String> MyValues;
...
MyValues.push_back("mycar");
MyValues.push_back("aball");
...
String value = MyValues[ComboBox1->ItemIndex];
...
hold a list(vector/array whatever you want) containing the name and value pairs. When selecting a name look the value up in the list.
Related
If I have an array, [Joe, John, Adam, Sam, Bill, Bob] and I want to try to add this to a new row by doing SpreadsheetApp.getActive().getSheetByName('Sheet4').appendRow([array]); , what happens is that the entire list of names goes into 1 cell. Is there a way to break this up so they file away into the same row, but different columns? I need to continue using appendRow however.
I get this:
But I really want to have it look like this:
var my2DArrayFromRng = datasheet.getRange("A:A").getValues();
var a = my2DArrayFromRng.join().split(',').filter(Boolean);
var array = [];
for (d in a) {
array.push(a[d]);
}
SpreadsheetApp.getActive().getSheetByName('Sheet4').appendRow([array.toString()]);
You are converting your array to a string before you post it which is causing your issue.
Do not use the array.toString() method inside append row. Instead just append the array as it is.
SpreadsheetApp.getActive().getSheetByName('Sheet4').appendRow(array);
I had to automate scenario where i get First Name and email address , which i had stored then i need to assert that value with drop down box that its not present.
Here is HTML code for my Page
<select id="Customer" name="Customer" class="valid">
<option value="raj777#gmail.com">123123123 (raj777#gmail.com)</option>
</select>
It contained multiple entries ,
I need to verify that my given text does not exist in it.
I tried this but it does not works
assertNotEquals(fname+" "+em, driver.findElement(By.xpath("//*[#id='Customer']")).getText());
Thanks In Advance !!!
Follow the below process:
Get the text of each element in the dropdown ('option' elements)
Strote the values in a list or array of string.
See the list or array contains your Name & mail id value.
or if u want to assert only, then in for-each loop of the array or list:
Add t
he assert statement in try-catch block.
In catch block, each time execution comes to this block, increase an integer.
After the fr-each loop, check the integer value is equal to yor list or array size.
Code sample for the first scenario:
driver.findElement(By.cssSelector(".trb_outfit_sponsorship_logo_img"))
.click();
System.out.println(dri.findElement(
By.cssSelector(".trb_outfit_sponsorship_logo_img")).getSize());
List<WebElement> dropDownValues = dri.findElements(By
.xpath("//select[#id='Customer']"));
ArrayList<String> dropDownValuesasText = null;
for (WebElement eachValue : dropDownValues) {
dropDownValuesasText.add(eachValue.getText());
}
// boolean result = dropDownValuesasText.contains("Your FirstName & Email value");
//It will pass if your value is present in drop down
assertNotEquals(dropDownValuesasText.contains("Your FirstName & Email value"), true);
I have a listView with many fields and CheckBox next to each field. Screen similar to a FaceBook Profile screen with Privacy setting to each field. So friends can not see those fields if marked as Private.
On selection of CheckBox, i have to create a comma separated String.
Example,
FirstName Text ---> isFirstNamePrivate boolean
LastName Text ---> isLastNamePrivate boolean
...
I have to create a
String str = "FirstName,LastName"
if both are marked as Private.
If only isFirstNamePrivate is true then
String str = "FirstName"
Also if i receive a comma separated String from Service, with that i have to make those Boolean array.
Given::
String[] fieldNamesArray = "field1","field2","field3","field4","field5"};
Boolean[] isfieldPrivate = {true,false,true,false,true};
// fieldNamesArray.length will be equal to isfieldPrivate.length
Need to create below commaSeparatedStr from above given arrays.
//
String commaSeparatedStr = "field1,field3,field5";
Question is:
1) What is the optimized way to create a comma separated String.
2) What is the optimized way to create the Boolean array from the commaSeparatedString avoiding for loop on commaSeparatedStr .contains(str[n])
Given::
String[] fieldNamesArray = "field1","field2","field3","field4","field5"};
String commaSeparatedStr = "field1,field3,field5";
Need to create below Boolean array with commaSeparatedStr from above 2 arrays.
Boolean[] isfieldPrivate = {true,false,true,false,true};
// fieldNamesArray.length will be equal to isfieldPrivate.length
//
Where is the question part here?
If you are asking for a suggestion:
If there are 5 fields and first 3 are selected, make your string like
{1,1,1,0,0}
and pass it to your webservice. This would lighten the data package size.
I have an array, lets call it _persons.
I am populating this array with Value Objects, lets call this object PersonVO
Each PersonVO has a name and a score property.
What I am trying to do is search the array &
//PSEUDO CODE
1 Find any VO's with same name (there should only be at most 2)
2 Do a comparison of the score propertys
3 Keep ONLY the VO with the higher score, and delete remove the other from the _persons array.
I'm having trouble with the code implementation. Any AS3 wizards able to help?
You'd better use a Dictionary for this task, since you have a designated unique property to query. A dictionary approach is viable in case you only have one key property, in your case name, and you need to have only one object to have this property at any given time. An example:
var highscores:Dictionary;
// load it somehow
function addHighscore(name:String,score:Number):Boolean {
// returns true if this score is bigger than what was stored, aka personal best
var prevScore:Number=highscores[name];
if (isNaN(prevScore) || (prevScore<score)) {
// either no score, or less score - write a new value
highscores[name]=score;
return true;
}
// else don't write, the new score is less than what's stored
return false;
}
The dictionary in this example uses passed strings as name property, that is the "primary key" here, thus all records should have unique name part, passed into the function. The score is the value part of stored record. You can store more than one property in the dictionary as value, you'll need to wrap then into an Object in this case.
you want to loop though the array and check if there are any two people with the same name.
I have another solution that may help, if not please do say.
childrenOnStage = this.numChildren;
var aPerson:array = new array;
for (var c:int = 0; c < childrenOnStage; c++)
{
if (getChildAt(c).name == "person1")
{
aPerson:array =(getChildAt(c);
}
}
Then trace the array,
am confused. I have an array of 'keys' where each key has a number. I have an array of my current row of data.
Now I need to fill a new array, where we match the key and value like this:
var template = HtmlService.createTemplateFromFile('box'); //MAAK FORMULIER KLAAR, HIER ALLE VARIABELEN DIE UIT DE RECORD KOMEN
template.action = ScriptApp.getService().getUrl();
template.ID=data[keys.key_ID];
template.AccountManager=data[keys.key_AccountManager];
template.Status=data[keys.key_Status];
template.Terugbeldatum=data[keys.key_Terugbeldatum];
template.Schoolnaam=data[keys.key_Schoolnaam];
template.Bezoekadres=data[keys.key_Bezoekadres];
template.Huisnr=data[keys.key_Huisnr];
template.Postcode=data[keys.key_Postcode];
template.Plaats=data[keys.key_Plaats];
template.Telefoon=data[keys.key_Telefoon];
template.Website=data[keys.key_Website];
template.Voorletters=data[keys.key_Voorletters];
template.Voornaam=data[keys.key_Voornaam];
template.VVAS=data[keys.key_VVAS];
template.Achternaam=data[keys.key_Achternaam];
template.Functie=data[keys.key_Functie];
template.Vakantieregio=data[keys.key_Vakantieregio];
template.LAS=data[keys.key_LAS];
template.LASDatum=data[keys.key_LASDatum];
template.ZelfstandigeInkoop=data[keys.key_ZelfstandigeInkoop];
template.Gespreksverslag=data[keys.key_Gespreksverslag];
template.SeminarDatum=data[keys.key_SeminarDatum];
template.AfspraakDatum=data[keys.key_AfspraakDatum];
template.Statushistorie=data[keys.key_Statushistorie];
template.Gesprokenmet=data[keys.key_Gesprokenmet];
template.Verantwoordelijke=data[keys.key_Verantwoordelijke];
template.TelefoonnummerV=data[keys.key_TelefoonnummerV];
template.row=row;
template.Emailadres=data[keys.key_Emailadres];
template.EmailadresV=data[keys.key_EmailadresV];
template.welkom = false;
Result:
http://imm.io/UP5b
Just a few variables get it into the template array, the rest is 'null' ???
When I do a
Logger.log(data[keys.key_Exxx]);
the value is there just fine.
Cannot I assign so many variables into Template this way?
Looks like there is something wrong using Copy-Paste, template.TelefoonnummerV=data[keys.key_TelefoonnummerV]; It seems like there is an extra character after the _ ??? I have been using a regex-tool to replace some text. Strange. – Riel yesterday