How to Scroll two datawindows simultaniously at a time? - powerbuilder

I have two datawindows with same number of columns and it is Freeform. I have arranged columns one after another(vertically).
How to scroll two datawindows simultaneously at a time in Powerbuilder 10.5?

You probably want to use the ScrollToRow method on the second datawindow. However, since you have arranged your columns in a long vertical row, it is unclear if this will work for you.
There is also a SetColumn method on datawindow controls but this does not 'scroll' to the column to make it visible.
Datawindow controls also have ScrollVertical and ScrollHorizontal events which you might use as well.
Look up these methods in PowerBuilder Help for additional information.

Put this code in the dw_1 ScrollVertical event to sync the dw_2.
dw_2.Object.datawindow.verticalscrollposition = scrollpos

If there is a link between the data of the 2 datawindows (there must be one, otherwaise, I do not see your point), you might consider to create a single datawindow.
Instead of
select col1A, col2A,...colnA from tableA
select col1B, col2B,...colnB from tableB
You would have
select col1A, col1B, col2a, col2B,.... from tableA, tableB where ...
Some caveats:
As indicated, you need a link between the 2 tables.
Update might be trickier: you can only define in the datawindow
painter one table to be updated. Programmatically, it is possible to
change that, however.


Delphi: TAdoTable.Insert not really an Insert?

I have two ADO Tables linked as master/details tables, tblCategory (master) and tblItems (details). Both tables have its own grid, and displayed in the same form. I also have data aware controls (dbedits).
Say, currently I'm at: Category=Books, No of Items=10 records, and pointing at record number 5 in the grid. I want to add a new record to the item, so I use:
The problem is, instead of adding a new row, the grid and the db aware controls are showing the current record (rec No 5). Not inly that, it seems the record is in edit mode too. After I cancel it and repeat the Insert command, only then the new row appeared.
How to fix this, so each time I use tblItems.Insert it always add a new and empty row :)
Nevermind, I think I know what caused it. It's the db aware controls. After the insert command, user will input data. This makes the db aware control receives focus and it automatically sets its position to the current record and displays it.
The solution is to use non-db-aware controls instead, and set the behavior programatically

How to sort a QuantumGrid on data from a different column

Is there a way to sort Devexpress QuantumGrid rows on data from a different column other than the one whose header has been clicked? For example, when the header of column A is clicked the rows of the grid are sorted on the data from column B. Visually it should still appear that it is column A that has been sorted as the sort glyphys will be shown in column A's header.
#norgepaul you must check the DevExpress Support Center for the questions related to the DevExress products, This site has thousands of answers and articles related to its products.
check theses links
Sorting by other field (when clicking header) in ExpressGrid 6|P0|83
I don't have DevExpress here to check, but i would look to see if there is a custom sort event. like OnCustomSort, where you get to decide whether a value or cell sorts higher or lower. I think you'll have the ability to know what rows are being compared, so you could look across to B cells, and make your own comparision.

how to copy checked rows to another datawindow?

So I have two datawindows, and in the first DW I have a checkbox per row. Now, I want to copy/send the checked or selected rows to the 2nd DW on a click of a button. Can you please enlighten me on how to do this? TIA. :)
This depends upon how you have the datawindows set up. If they are using the same datawindow OBJECT you can simply use the RowCopy method.
dw_1.rowsCopy(<start dw_1 row number>, <end dw_1 row number>,
Primary!, dw_2, <dw_2 row number BEFORE which you wish to add
the rows>, Primary!)
where dw_1 has the rows to copy and dw_2 is the target.
If the datawindows use different datawindow objects (different number of columns, etc.) you need to loop through the source datawindow rows and do a series of SetItem calls to place the data into the target datawindow.

GtkTreeView Column Header Click Event

I have a question. I have a GtkListStore and a GtkTreeView, and I want to sort the GtkListStore and update the result to the GtkTreeView when the user clicks on a certain column of the GtkTreeView. I am assuming that the columns are clickable, and cannot be re-ordered, so the numerical order of the columns can be used to set the sorting column's index. But I cannot seem to find which signal gets emitted when the user clicks on the header of a particular column. I have gone through the GTKMM documentation time and again, but it does not seem to be mentioned!
Use Gtk::TreeView::get_column(<column-no>) to get a particular column and attach to its "clicked" signal using Gtk::TreeViewColumn::signal_clicked():
Gtk::TreeViewColumn* col = myview.get_column(SOME_COLUMN_NUMBER);
That's not how you're supposed to do it.
There can be several views hooked up to the same model; sorting is not something you do to the model, it's something you do to the view.
See the GtkTreeSortable interface (and its GtkTreeModelSort implementation).

TDBGrid columns design time or run time?

I am using TDBGrid for the first time.
I didn't even notice the Columns property in the object inspector and everything went just fine: the grid was filled.
Then I saw the Columns property and tried it. When I use the object insector to add items to the Columns property of the grid, they do not all of them show up at run time. To me, it looks like the FieldName property is important. It looks like it is correct, but there are no values in some columns.
If I leave this property blank (no columns at all) it seems that the control populates it itself at run time and I do see all the columns. I could live with that. When I set column titles at run time it works, but setting column width does not.
[Update] Thanks for the feedback. I am learning slowly. Now I see what is happening. I wanted three of the five columns to be calculated. Two are gotten from INNER JOINs and the third from an SQL 'cast' of SELECT ... FROM_UNIXTIME(<table>.time_stamp).
If I do not define the columns at design time then these values are populated at run time when I execute my SELECT. Cnn anyone tell me how to set things up at design time? Thanks
There is no difference in functionality between runtime and designtime set up columns. That is: what can be done designtime can also be done runtime, and vice versa.
When te Columns property is kept empty, the grid fills it by default with all fields it finds in the linked dataset, once the dataset is opened. All column specific settings, such as alignment, width, title caption, etc... are set to default, based on the type, length and name of the corresponding field. This is the lazy way which sure could be sufficient.
You could deside to use your own setup or modification of the columns property, for one or more of the following reasons:
Change the order of the dataset fields in which they must appear in the grid,
Truncate the width of text fields (especially VarChar fields or Char fields with a large length normally result in colums that are too wide for normal presentation and/or user interaction),
Change the alignment of the fields (normally numeric fields are right aligned by default),
Hide one or more fields from the dataset,
These own settings can be done desingtime as well as runtime.
Using the designtime columns editor is the preferred and RAD way in need of these customizations. Open the editor by double clicking the grid or the property, or via the grid's context menu. If the linked dataset is active then the command Add all fields is enabled, which does exactly the same as if you did not select any field at all, i.e. the default behaviour as described in the second paragraph.
The best way to define the columns on a dbGrid is to doubleclick the dataset in order to create variables that the form knows about (persistent fields). You can edit various properties of these variables such as DisplayLabel, DisplayWidth and DisplayFormat.
You can also add calculated fields by double clicking on the dialog box which appears when you double click on the client dataset.