Using System.windows.forms.tablelayoutPanel in usercode

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
KJG
Posts: 18
Joined: Wed Jul 18, 2018 9:08 am

Using System.windows.forms.tablelayoutPanel in usercode

Post by KJG » Sun May 23, 2021 5:50 pm

Sirs,

I have a table that has been given me by the developers. In Rx Spy I have a definition of
container[@controltype='System.Windows.Forms.TableLayoutPanel']

In my user code I want to find out how many rows are in the table (it is populated from a DB) and click the control at (column, row).
When I define my usercode from the recording, I choose to pass the container defined above as an adapter or RepoItemInfo parameter.

The main issue I have starts right at the beginning as I cannot work out in my usercode how to cast the RepoItemInfo to System.Windows.Forms.TableLayoutPanel so that I can check the RowCount Property, for example.

I just want to do something like ClickOnTable(Row, Column, TableObject).

Can someone advise what to do?
I have not coded for a long time and this escapes me.

KJG
Posts: 18
Joined: Wed Jul 18, 2018 9:08 am

Re: Using System.windows.forms.tablelayoutPanel in usercode

Post by KJG » Sun May 23, 2021 6:10 pm

Just to add to this ... Here is my usercode attempt ...

Code: Select all

        public void SetRowAndColumn(int Row, int Column, Adapter Table)
        {
        	ProjectRepository myRepo = ProjectRepository.Instance;
        	CheckBox myCheckBox = ((SystemWindows.Forms..TableLayoutPanel)myRepo.ConnectionForm.DesignerPanel.Table).GetControlFromPosition(Column, Row) as CheckBox;
I get an error on compiling
Cannot convert type 'Ranorex.TabPage' to 'SystemWindows.Forms.TableLayoutPanel' (CS0030)

I am passing Table as Adapter but have tried RepoInfoItem with exactly the same result.

Can anyone point me in the right direction?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using System.windows.forms.tablelayoutPanel in usercode

Post by odklizec » Mon May 24, 2021 8:33 am

Hi,

At first, please post a Ranorex snapshot (NOT screenshot) of the problematic element and full xpath as you have it stored in repository. This would help us to understand your UI and eventually, provide a reasonable answer. Without seeing, at very least, a Ranorex snapshot, it's more or less a guess work. Thanks.

And please, delete the duplicated post you created here:
viewtopic.php?f=13&t=19516&p=66255#p66255
Making multiple posts about the same problem does not help with faster answer ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

KJG
Posts: 18
Joined: Wed Jul 18, 2018 9:08 am

Re: Using System.windows.forms.tablelayoutPanel in usercode

Post by KJG » Mon May 24, 2021 10:00 am

Apologies for not deleting the other post. Completely slipped my mind. Done now.

I have attached a snapshot of the TablePanelLayout. The basic requirement is to be able to get a control according to it column and row in the table (regardless of type) and click in the centre of the control or the table cell.

Thanks for your assistance...
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using System.windows.forms.tablelayoutPanel in usercode

Post by odklizec » Mon May 24, 2021 10:10 am

Hi,

Thanks for the snapshot.

Well, at first, you are using a pretty old Ranorex, version 9.3.3. This version is obsolete and no longer supported. Please update to most recent 9.5.1.

At next, the 'table' you are working with is not table at all. At least Ranorex does not recognize it as table (if you mean this element... /form[@controlname='GlobalConfigForm']/?/?/tabpage[@controlname='bodDesignerTP']//container[@controlname='bodTableColumnsTLP'])
Therefore, you cannot work with it as with "Ranorex.Table" element. Luckily for your, there is available RowCount property, from which you can get "table" row count...
TableRowCount.png
No code required then. Simply use GetValue action to get the value from RowCount property. Hope this helps?
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration