Delphi QuantumGrid GetSelectedRowIndex after sorting - delphi

I have D2006 and I am using DevExpress QuantumGrid 6 in a project. I am using it in unbound mode. I have several rows and I need to trigger an action when user select a row and click a button. That works fine when the grid is not sorted by user. I use this code to know the row the user has selected:
index := cxMainTable.DataController.GetSelectedRowIndex(0);
cxMainTable.DataController.Values[index, 0];
But when the user sort the grid by clicking in a column header, the index returned is right for the current order displayed but the values the second line returns is the value that you would expect if the grid was not sorted.
Thanks.

You have to distinguish between records and rows.
Maybe TableView.DataController.FocusedRecordIndex is what you want?

Related

Comparison between current row, previous row and next row in Talend

I want to know if my value is included in an interval consisting of the previous row and the next row. How to do it in Talend?
I tried a tMemorizeRow function where I save 3 lines each time, but encountered a java.lang.NullPointerException exception as when I am on the first line it does not know the next row I saved.
What am I missing?
You can try this : add a column "sequence" with value as Numeric.sequence("s1",1,1)to your data : this way you'll know this exact order between rows in your flow (you can do it in a tMap). Redirect the tMap to a tHashOutput component (if you can't find in the palette, add it through Project Parameters>Designer>Palette>Technique , this component is hidden by default).
Then you'll need an other subjob, with 3 tHashInput : one for your main flow, and the two others as lookup : then you'll be able to join rows with previous and following one , thanks to your 'sequence' field.
Then in tMap_2 you'll be able to compare values from mainFlow with Previous and Next flows.

How to use index function to return the value of the last cell that isn't blank

I am keeping a dynamically updated Google Sheets file of team performance where certain cells are updated by a team member, and there is a dashboard at the top that pulls only the most recent numerical values inputted. I need to find a formula for the dashboard section at the top to return the value of the last cell that isn't blank in a non-sequential selection. for example, the cells would be:
B30, B43, B56, B69, B82, etc.
Is there a way to use CHOOSE, INDEX, or something similar to do so?
the answer is: don't use INDEX. for a last non-empty row use:
=ARRAYFORMULA(INDIRECT("B"&MAX(IF(B:B<>"", ROW(B:B), ))))
=IF(B294<>"", B294,
IF(B273<>"", B273,
IF(B252<>"", B252,
IF(B231<>"", B231,
IF(B210<>"", B210,
IF(B189<>"", B189,
IF(B168<>"", B168,
IF(B147<>"", B147,
IF(B126<>"", B126,
IF(B105<>"", B105,
IF(B84 <>"", B84,
IF(B63 <>"", B63, ))))))))))))

Automatically fill out textbox doble clicking on an item in a listbox

Another beginners question, but this time about MS Access Controls.
I have a form where I have a list box full with many items.
What I need to do is when I double click on one of this item stored in the list box should all the textbox filled with an item stored on a different field from the same row where from my table.
I checked many tutorials already but didn't found a good solution.
Thanks for any help!
EDIT:
I have a table with several fields. The list box have the items from the first field(ID). The rest of the fields(Tile, Delivery Date, etc...) represented by text boxes in my form.
When I double Click on one item from the list box will populate the text boxes.
If I select the 5th item from my list box which represents the 5th row from my table every text box should have their item from the same row from the fields represented in the table.
I only want to edit the data stored in the table with this form.
Ok I finally get a solution for this one.
I using the DLOOKUP to get the data pulled to my form after the double-click event.
Dim ctrloop
For Each ctrloop In Me.lbReportID.ItemsSelected
strReportID = Me.lbReportID.ItemData(ctrloop)
Next ctrloop
Me.txtTitle = DLookup("[Title]", "tblreports", "[ID No] = '" & strReportID & "'")
The loop stores all report ID I have in my table. The DLOOKUP using this as a filter. It's like the WHERE in SQL.
When the program run will fill out my Title textbox looking through the title field in my tblreports table filtered with the strReportID.
It's working similarly like this SQL query which I using in a different textbox:
SELECT tblReports.[ID No]
FROM tblReports
WHERE (((tblReports.WorkPacage) = 'CDS'))
AND (((tblReports.State) <> 'Complete'));

Apply 3-color scale to an entire row in Excel 2010.

I have an table in an MS Excel 2010. The table has two columns. The first column is a name of a person (Col A), the second column is the marks that the person secured in an exam (Col B).
I am applying conditional formatting. If I choose the following wizard
Home > Conditional Formatting > Format all cells based on their values
I can color the Col B on a 3-color scale. This is exactly what I want. However, I want it for the entire row and not only the cell in Col B. I want the name also to be formatted in the same color as the marks.
Anyone knows how to do this?
I have already looked around a bit. The following came close to did not solve the particular problem that I am trying to.
http://www.howtogeek.com/howto/45670/how-to-highlight-a-row-in-excel-using-conditional-formatting/
Conditional Formatting Rows Based on Date
You're probably going to have to use VBA code for this.
Right click the worksheet label and select 'View Code'
Inside the code window, paste in the following code:
Sub RunMe()
Dim xRng As Range, xCell As Range
With Me
Set xRng = .Range(.Cells(2, 2), .Cells(.Rows.Count, 2).End(xlUp))
' Change the first '2' above to reflect the starting row of your data
For Each xCell In xRng
xCell.Offset(0, -1).Interior.Color = xCell.DisplayFormat.Interior.Color
Next xCell
End With
End Sub
Now every time you run the macro (Alt-F8, select macro), column A will be formatted with the conditional formatting assigned to column B.
If you want this process to be automatic, change:
Sub RunMe()
to something like:
Private Sub Worksheet_Activate()
' This will run the macro whenever the worksheet is selected
or you could assign the code to a keyboard shortcut or a command button etc.
If you would like the code to run every time the file is opened, saved closed etc, add the code instead to the ThisWorkbook code window (although you'd have to alter the code slightly as 'Me' is referencing the particular worksheet in which the code is placed).

do some calculations in a table using dropdowncombo

I have a field in my database called 'Stock'. It displays how many items are there remaining for sale.Now I have a dropdowncombo with values like 1,2,3 etc... So now when I select an item in the grid and click the button SELL I would like the 'Stock' field of the item in question (in the grid) to decrease by the amount that was in the combo. So if the 'stock' was 100 and I sell 5 (dropdowncombo value) I would like the grid value to display now 95. I hope you know what I mean... I could do this with inserting a calculated field but I do not want to. Better an UPDATE ... Any ideas
something like UPDATE MyTable set STOCK = (Mytable.fieldbyname('stock').asInteger - dropdowncombo1.value)
dont have delphi here with me so unsure does this work on selected record in the grid...
abstable1.edit;
abstable.FieldByName('stock').value := abstable.FieldByName('stock').value - strtoint(cxcombobox1.text);
abstable1.Refresh;
This does the job ...

Resources