How to set the cell value for displayed cells only? - vcl

I have some data I want to display in a StringGrid. This data contains many rows with some pretty static columns but also two columns that need web-API lookups and take some time to gather. SO when I try to set these cells in the OnShow of the StringGrid (or any other "Init") I get a long delay until the cell values are set.
What I would like to do is only look up the values for those cells that are currently displayed (and not all of them at once).
How Do I find out which rows are currently displayed? Is there an event I can use?

Related

Is There a More Efficient Way of Determining Whether a Table Row Spills Over Into the Footer Than Looping Through All Cells?

I'm currently using Microsoft Word 2016 VBA to programmatically set the AllowBreakAcrossPages setting so that if a row's contents overlaps the footer contents, I toggle the setting so that the row can break across pages. To solve this issue, I'm thinking about looping through all the cells of each table in the document and get the wdVerticalPositionRelativeToPage.Information of the last characters in each cell and comparing it to the footer's height relative to the page. If the last character's height is greater than the footer's, I set the row to break across pages. You can imagine that this is taking a while in a document that has many tables and cells. Is there a more efficient way to know if the row contents overlap the footer contents than looping through each cell in the row to see if a cell is causing the row to overlap the footer?
I tried using the row height property but discovered that if the HeightRule property of the specified row is wdRowHeightAuto then that means I can't access the row height via VBA.
I discovered that it's possible to use wdVerticalPositionRelativeToPage.Information with a row by row comparison of the prior and next rows like described in another posting - https://stackoverflow.com/a/14753231/4372244.
The only problem with that solution is that it doesn't work for the last row in a table or if it's the last row on a page.
Therefore, I'm examining a cell by cell solution.

How do I check to which row area field a cell in a pivottable belongs to?

I have a PivotTable in compact form layout (default layout) with multiple row area fields. This results in multiple grouping levels with buttons to collapse or expand rows.
I want to modify a cell depending on the grouping level the row is in.
How can I check in which row the cell is in?
The only idea I had so far was to check the value of the leftmost cell in the corresponding row and compare it with each item from each rowField.
But I guess there is a smarter way?
It took me a while. But at the end I just needed PivotCell.RowItems.Count
Depending on the Count result I can new manipulate the cell.

Adding a row (not a column) of a type (checkbox,dropdown) in datagridview

I have a datagridview that is only two or three rows long. It has 7 text columns, one for each day of the week (Monday - Sunday). I'm creating a scheduler, so basically on the left side I have added text to the row headers to assign to it. I.e. Enabled (let's say for Tuesday), start time and end time. This allows the user to schedule as need be.
Here's a picture of it right now:
What I want to do is possibly change the enabled row, or the start/end time to a particular type. So the enabled will be a checkbox and the start/end times will be drop down menus instead of these text boxes.
My question is, what's the "best" way to add a row of a certain type? Obviously columns are done easily, but is there a common method for a row type other than looping through and adding individual cells of that type to the datagridview?
The type of each cell can only be pre-determined by the column, not the row. As a result, you're going to have to add each cell individually. You can actually put a cell of any type anywhere you want. You simply create a cell of the desired type and assign it to the Item property of the grid, e.g.
myDataGridView(columnIndex, rowIndex) = newCell
You will simply have to use a For loop to do that for each valid column index with a single row index. Note that you'll have to create a new cell for each column, not reuse the same one.

Where is this EXCEL Sheet's data stored?

I am stuck at this problem which involves extracting data from a excel spreadsheet. And the values are "hidden" behind a "interface". I was given a excel file with the coordinate system and for the specified coordinates, when you click on them, a value is displayed to you on the small window above the spreadsheet.
I need all these values and I am sure that I could extract them all at once, not one by one.
So I need to gather all the values that are assigned to the specific coordinates and implement it in my program. Also there is this red-green interface which points out if the value is above a specified number.
But how do I get to the values?
Excel Spreadsheet Link.
They are stored in that row by column. The reason that you cannot see them when you open it is that the size of the column have been reduced. To see the actual number in the row by column, just expand that column by dragging it to the right. For example, in spreadsheet EEM_80_Eini+Ausi, if you look at cell B3 and expand the row and column, you will see the number .2450610558 inside that cell.

Is it possible to set vb.net datagridview cell alignment without modifying whole column?

I am trying to set the alignment of a specific cell in a row/column to be right aligned. However I do not want to set the whole row, or whole column to right aligned. Is it possible to set the cell only? From what I've seen online I'm starting to think it isn't possible.
You would need to hook up to the RowDataBound event. This fires as each row is databound. Check that the row is a data row (as opposed to a header or footer). Then check the value in the column you are interested in. If the value meets your criteria for right justification then apply that to the column in question.
Note if you are using AlternateItemTemplate then check both Item rows and AlternateItem rows.
I've used this method to say change the backround colour of values that fall outside a range.