Vb Changing column index not displayed column index for gridview - vb6

Hi every one i have a problem which i need to change the index of my gridview. Not only displayed index. Cause i need it to populate into another document.
Dim haa As Int16 = DataGridView1.ColumnCount
DataGridView1.Columns(1).Index = haa - 1
I have tried this and it says Property Index is readonly.
Any idea how to make it dynamic so that ill be able to alter it ??
I have tried doing this too it works for displaying but when populating it does not work.
DataGridView1.Columns(1).DisplayIndex = haa - 1
Aside from this i tried this too
DataGridView1.Columns.Move(DataGridView1.Columns["Total Of Field1"], haa -1);
However it does not work.

Hi Every one i found a way to really shift shit out of a column. This is the way.
Dim abc As DataGridViewColumn = New DataGridViewColumn
abc = DataGridView1.Columns(1)
DataGridView1.ReadOnly = False
DataGridView1.Columns.RemoveAt(1)
DataGridView1.Columns.Add(abc)
So i just take out the column i want to put at the last and append it back.
But i guess its a really bad way anyone has better idea ?

Related

Google Sheets add a Permanent timestamp

I am setting up a sheet where a person will be able to check a checkbox, in different times, depending on the progress of a task. So, there are 5 checkboxes per row, for a number of different tasks.
Now, the idea is that, when you check one of those checkboxes, a message builds up in the few next cells coming after. So, the message is built in 3 cells. The first cell is just text, the second one is the date, and the third one is time. Also, those cells have 5 paragraphs each (one per checkbox).
The problem comes when I try to make that timestamp stay as it was when it was entered. As it is right now, the time changes every time I update any part of the Google Sheet.
I set u my formulas as follows:
For the text message:
=IF($C4=TRUE,"Insert text 1 here","")&CHAR(10)&IF($E4=TRUE, "Insert text here","")&CHAR(10)&IF($G4=TRUE, "Insert text 3 here","")&CHAR(10)&IF($I4=TRUE, "Insert text 4 here,"")&CHAR(10)&IF($K4=TRUE, "Insert text 5 here","")
For the date:
=IF($C4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($E4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($G4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($I4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($K4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")
And for the time:
=IF($C4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($E4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($G4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($I4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($K4=TRUE,(TEXT(NOW(),"HH:mm")),"")
And it all looks like this:
I would appreciate it greatly if anyone could help me get this to work so that date and time are inserted after checking those boxes and they don´t change again
Notice that your struggle with the continuous changing date time. I had the same struggle as yours over the year, and I found a solution that works for my case nicely. But it needs to be a little more "dirty work" with Apps Script
Some background for my case:
I have multiple sheets in the spreadsheet to run and generate the
timestamp
I want to skip my first sheet without running to generate timestamp
in it
I want every edit, even if each value that I paste from Excel to
generate timestamp
I want the timestamp to be individual, each row have their own
timestamp precise to every second
I don't want a total refresh of the entire sheet timestamp when I am
editing any other row
I have a column that is a MUST FILL value to justify whether the
timestamp needs to be generated for that particular row
I want to specify my timestamp on a dedicated column only
function timestamp() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const totalSheet = ss.getSheets();
for (let a=1; a<totalSheet.length; a++) {
let sheet = ss.getSheets()[a];
let range = sheet.getDataRange();
let values = range.getValues();
function autoCount() {
let rowCount;
for (let i = 0; i < values.length; i++) {
rowCount = i
if (values[i][0] === '') {
break;
}
}
return rowCount
}
rowNum = autoCount()
for(let j=1; j<rowNum+1; j++){
if (sheet.getRange(j+1,7).getValue() === '') {
sheet.getRange(j+1,7).setValue(new Date()).setNumberFormat("yyyy-MM-dd hh:mm:ss");
}
}
}
}
Explanation
First, I made a const totalSheet with getSheets() and run it
with a for loop. That is to identify the total number of sheets
inside that spreadsheet. Take note, in here, I made let a=1;
supposed all JavaScript the same, starts with 0, value 1 is to
skip the first sheet and run on the second sheet onwards
then, you will notice a function let sheet = ss.getSheets()[a]
inside the loop. Take note, it is not supposed to use const if
your value inside the variable is constantly changing, so use
let instead will work fine.
then, you will see a function autoCount(). That is to make a for
loop to count the number of rows that have values edited in it. The
if (values[i][0] === '') is to navigate the script to search
through the entire sheet that has value, looking at the row i and
the column 0. Here, the 0 is indicating the first column of the
sheet, and the i is the row of the sheet. Yes, it works like a
json object with panda feeling.
then, you found the number of rows that are edited by running the
autoCount(). Give it a rowNum variable to contain the result.
then, pass that rowNum into a new for loop, and use if (sheeet.getRange(j+1,7).getValue() === '') to determine which row
has not been edited with timestamp. Take note, where the 7 here
indicating the 7th column of the sheet is the place that I want a
timestamp.
inside the for loop, is to setValue with date in a specified
format of ("yyyy-MM-dd hh:mm:ss"). You are free to edit into any
style you like
ohya, do remember to deploy to activate the trigger with event type
as On Change. That is not limiting to edit, but for all kinds of
changes including paste.
Here's a screenshot on how it would look like:
Lastly, please take note on some of my backgrounds before deciding to or not to have the solution to work for your case. Cheers, and happy coding~!

QTP UFT How to find a row number and column number? Angular JS

When I spy the table it shows just browser - Page - WebElement and also UI is developed in Angular JS.
I there any way to find row number and column number? By the way I am using UFT/QTP
From the source-code's image which you have attached, it is quite evident that the webElement corresponding to the rows have class = "ui-grid-row ng-scope". So, you can make use of descriptive programming. I assume that you already have added the object Browser(...).Page(...) to your OR.
Set rowDesc = Description.Create
rowDesc("Class Name").value = "WebElement"
rowDesc("Class").value = "ui-grid-row ng-scope"
Set objRows = Browser(...).Page(...).ChildObjects(rowDesc)
rowCount = objRows.Count 'This variable should now contain the total number of rows"
Now, this is just an idea which you can give a try. If it works for you, you can further enhance it to get the column count. If there is no way you can get the column count, then you can get the total cell count using the same method. In that case, you just need to change the value of property "class" to the one mentioned in the Object Spy Image("ui-grid-cell-contents ng-binding ng-scope"). Now you have Row Count and Cell Count. To get the column count, you can divide cell count by row count.(Again, this will give you correct answer ONLY IF there are same number of columns for each of tbe rows).

Clicking on specific row in a WebTable using UFT/QTP

I am having hard time clicking specific row in a Web Table. My code finding proper row, but when I use Child Item method it complains that Object is not found. Here is my code:
Desc = "Record to click"
If Browser("B").Page("P").WebTable("W").exist(10) Then
totalRows = Browser("B").Page("P").WebTable("W").RowCount()
For RowNum = 1 To totalRows
If aDesc = Browser("B").Page("P").WebTable("W").GetCellData(RowNum,2) Then
Browser("B").Page("P").WebTable("W").ChildItem(RowNum,2,"WebElement",0).click
End If
Next
End If
I spied on the value in the row it is Web Element, I tried to use Link- didn't work. Also I tried to Child Item(aDesc,2,"WebElement",0)- didn't work either. I used 0 for the index because there is only one element in the row - simple text. I keep getting this error in many other tests. On rare occasion this approach works in some tests, but most of the time it complains for absence of object.
Thank you very much for your help!
It happened with me as well. When I researched, I found in some of the old HP blogs that ChildItem method does not works correctly with WEBElement, but that was for QTP 9.0, and I was using 12.02.Anyhow, I can't figure out why its happening, and ended up using the following -
Set oExcptnDetail = Description.Create
oExcptnDetail("micclass").value = "WebElement"
oExcptnDetail("html tag").value = "TD"
Set chobj=Browser("").Page("").WebTable("Code").ChildObjects(oExcptnDetail)
chobj(0).Click
On a side note, in order to check a webelement/link exist in a certain row and column, use the following.
Browser("B").Page("P").WebTable("W").ChildItemCount(2,2,"WebElement")
Getcell data will return you anything that is in the desired row and column irrespective of what it is (link,webelement etc) and hence your assumption of if loop will go wrong.
Try this:
Browser("B").Page("P").WebTable("W").object.rows(rownum-1).cells(colnum-1).Click
I was trying to click the first link in my table and this code clicked the item
Set oDesc = Description.Create()
oDesc("html tag").Value = "A"
Set rc = Browser("B").Page("A").WebTable("html id:=gridTable").ChildObjects(oDesc)
rc(0).Click
'num = rc.Count() 'get the number of link in a page
'For i=0 to num-1
'ref = rc(0).GetROProperty("href") 'get the “href”propety of the i th link
'MsgBox ref
'Next
or
Browser("B").Page("A").WebTable("html id:=gridTable").ChildItem(2,8,"Link",0).click
successfully clicks the link I needed

VB6 - Create subMenuItems programmatically

I'm working in a VB6 project and there is an existing menu, created with the menu creator. I am having trouble to insert subMenu programmatically in a MenuItem.
The first menu is File. It contains two menu items : Choice and Exit.
I would like to insert each row of a query (only the first column) at run time in Choice.
My recordset works well, but i need some help in the code below :
Do While rs_choice.EOF = False
'add column1 in Choice
'~Something~ = rs_choice.Fields("column1").Value
rs_choice.MoveNext
Loop
PS : No one MenuItems have defined index.
Can someone help me ?
Using the designer give Choice a single sub-item called mnuDynamic, give it an index of 0.
Loop the recordset loading new items:
Dim i as long
Do While rs_choice.EOF = False
If (i > 0) Then Load mnuDynamic(i)
mnuDynamic(i).Caption = rs_choice.Fields("column1").Value
rs_choice.MoveNext
i = (i + 1)
Loop

Tables got over-written

I want to loop thru a dbf and create word table for each record meeting the condition, and I got a one-page report with only the last rec in a single table. Look like all records are written to the same table. I tried to use n = n + 1 to place the variable as an element to the table
oTable = oDoc.tables[n]
But seems it only support numerical rather than variable ?
You have to add each table as you go, making sure to leave space in between them (because Word likes to combine tables).
You'll need something like this inside your loop:
* Assumes you start with oDoc pointing to the document,
* oRange set to an empty range at the beginning of the area where you want to add the tables,
* and that nRows and nCols give you the size of the table.
oTable = oDoc.Tables.Add(m.oRange, m.nRows, m.nCols)
oRange = oTable.Range()
oRange.Collapse(0)
oRange.InsertParagraphAfter()
oRange.Collapse(0)
After this code, you can use oTable to add the data you want to add. Then, on the next time through the loop, you're ready to add another table below the one you just filled.

Resources