How to disable the selected rows - powerbuilder

I have a data window with a checkbox. I want to disable the selected rows. How can I do that? Also, please explain to me the code below. I saw it online and it works fine but it only disable the first selected row. Thank you
dw_unreportedprall.object.sel.protect = '0~tif(GetRow()=' + string(ll_ctr) + ',1,0)'

I assume the variable 'll_ctr' holds the value for the row you are checking. If so you could try:
...'0~tif(IsSelected(' + string(ll_ctr) + '),1,0)'
Your code only works on a single row because the GetRow() method only gives you the current row (the one with focus) in a datawindow.


How to insert data into a TdxMemData in Borland Builder

I'm struggling to insert data into a TdxMemData which is linked to a grid by a TDataSourse.
The MemData -called PurchaseData- has 3 columns: Date (date), Place (string) and Value (currency).
I have a button that does the following:
PurchaseData->FieldByName("Date")->Value = TDateTime::CurrentDate().DateString();
PurchaseData->FieldByName("Place")->Value = "";
PurchaseData->FieldByName("Value")->Value = 0.0f;
Clicked once, it inserts a row normally and the data appears in a new row of the grid, but when clicking the button again I get a popup on the Insert() saying "Could not convert variant of type (Null) into type (String)".
I'm worried about the fact that the property "KeyFields" of the columns shows in its combo the field "RecId" besides the other 3 fields. I don't remember creating any column called RecId and if I did, I removed it. I can't figure out what it is and could not find help neither.
im not in a place to test this right now but changing it to this might work
PurPurchaseData->FieldByName("Place")->Value = String("");
if that doesnt work you it will be in the way you have set up your columns.
I had mapped the event OnSelectionChanged of the grid and read the data in the newly selected row. Unfortunately when PurchaseData->Insert() is called, the SelectionChanged event is fired right away. before the new row's data is set by the next lines. I got Null from the data read and did Bad Things with it like setting an edit->Text with it, thus the message in the popup.

How to get certain field from the arrayList object on spinner selection

I just created a spinner and make this spinner read from the database. and display them in the spinner. I already did that. But I want to right down the Id of the selected item.
for example : when I select the first raw called (1, tyat abdullah, sergurey )
I need the Id (1) only to be written down without the full record.
I need the Id (1) only to be written down without the full record.
Then when you are doing labels.add, only put the data you want to see
You can also use doctorsList.get(position) within the selection listener, and set the other text view accordingly.
For example, doctorsList.get(position).getId() seems to get the information you are asking for
simply use this to get the selected item index
int index = spinner.getSelectedItemPosition(); //this will give you the seleected item index
is that what you want ?
leme Know :)

Get the respective value from the array according to selected item position

I have a spinner and I'm getting its selected item position by MyOnItemSelectedListener. By the time I'm using an array adapter to load items to the spinner. I have loaded the items and it works perfectly. But I have a small problem. When I doesn't select a value then it shows position 0 but it has got the value of 1st array value. As shown in the below image,
What I want to do is when I haven't select a value then it should get any value from array. And when I select 1st item then only it should get 1st array value.
Array is a created from json response so it is not possible to add a item to array manually.
I have used How to make an Android Spinner with initial text "Select One" (aaronvargas's answer) to add slect option to spinner as 1st selection.
How can I achieve this? Any help will be highly appreciated.
You can use the logic like :
int selectedValue = -1;
//Means Item not selected
selectedValue = array[position-1];
I think you can use something like I have shown.
variable = 0;
//use ur logic here

setting QCombobox selected text to specific data column when using QTableView

I'm using a QCombobox that is using a QTableView to display a table of data. My code is (mostly) working right now except for a few details. One of them is that when I select a row, the combo box title is updated using the first column and I would like to display data from another column. How do I change that?
I tried overriding the currentText() method but it didn't work, it seems it is not used internally to update the combo box title. Does anyone have the answer?
This is what is happening now. My data is organized in 4 columns, the 3 first are boolean values while the 4th is a string. In this screenshot, I selected the "Data 3" cell. When I select it, that gets displayed on the combobox select field is "true", the value that is present on the first column of my selected row.
What I want to get is this :
I am trying to have the data from the 4th column being displayed on the combobox select field.
I found solution, but it is not the best approach. However try it, maybe it is one way to do this:
QString oldTxt;//somewhere
ui->comboBox->setView(new QTableView);
connect(ui->comboBox->view(),&QAbstractItemView::pressed,[=]() {
oldTxt = ui->comboBox->model()->data(ui->comboBox->view()->currentIndex()).toString();
qDebug() << ui->comboBox->model()->data(ui->comboBox->view()->currentIndex());
connect(ui->comboBox,&QComboBox::currentTextChanged,[=]() {
Main idea: catch selected by user value and set it as current text. Second connection is necessary because without it comboBox will set another value. Just to prove that it works another code snippet:
connect(ui->comboBox->view()->selectionModel(),&QItemSelectionModel::selectionChanged,[=]() {
As you can see, it is value selected by user, not value from first column.
I used here C++11 (CONFIG += c++11 to .pro file) and new syntax of signals and slots, but of course you can use old syntax if you want.
The proper solution was the one pointed out by hank : using QComboBox::setModelColumn().
Hank, I am posting this answer because I couldn't find out how to mark your comment as the accepted answer.

PowerBulder DropDownListBox inside a Datawindow

I have made a DropDownListBox inside a Datawindow.
Upon Item Change, I set and save the Value of the selected item in that DropDown in an INI File.
In my Open Event, I use setitem to Set the saved value in that dropdown.
The problem here is that it doesnt setfocus on that index of the selected item in those dropdown.
I also used, SetRow(), setcolumn(), SetText() just to make the Focusing of the Selected Text.
The problem on this one is I have like 100+ Items. When the chosen value is in the middle, let's say Index#50, the ScrollBar focus is still on the top Index#1, not at Index#50.
Any help? Thanks.
1) Try to play with SetRedraw
2) Try to use DDDW instead of DDLW. And use DDDW with integer index column. Sometimes builder fails with string "keys"
A) This is so much easier with a DDDW editstyle right in the datawindow. You just do a SetItem( row, column, value) to set the initial value in the dropdown.
B) That having been said, I would not call 100+ items in a listbox "effective UI design". I would evolve that into an editbox, with search-on-type capabilities, like you see in the Google search page.