Highlighted
Absent Member.
Absent Member.
1084 views

C# to VC

Hi,

Can anyone assist with changing below C# into Visual Cobol?

 subItems = new ListViewItem.ListViewSubItem[]
 {new ListViewItem.ListViewSubItem(item, "Directory"),
new ListViewItem.ListViewSubItem(item, dir.LastAccessTime.ToShortDateString())};

This is in the code block:-

 

*> TreeNode newSelected = e.Node;
declare newSelected as type System.Windows.Forms.TreeNode = e::Node

*>listView1.Items.Clear();
invoke listView1::Items::Clear

*>DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag;
declare nodeDirInfo as type System.IO.DirectoryInfo = newSelected::Tag as type System.IO.DirectoryInfo

*>ListViewItem.ListViewSubItem[] subItems;
declare subItems as type System.Windows.Forms.ListViewItem+ListViewSubItem[]

*>ListViewItem item = null;
declare item as type System.Windows.Forms.ListViewItem = null

* foreach (DirectoryInfo dir in nodeDirInfo.GetDirectories())
* {
* item = new ListViewItem(dir.Name, 0);
* subItems = new ListViewItem.ListViewSubItem[]
* {new ListViewItem.ListViewSubItem(item, "Directory"),
* new ListViewItem.ListViewSubItem(item, dir.LastAccessTime.ToShortDateString())};
*
* item.SubItems.AddRange(subItems);
* listView1.Items.Add(item);
* }

perform varying dir as type System.IO.DirectoryInfo through nodeDirInfo::GetDirectories
set item = new type System.Windows.Forms.ListViewItem(dir::Name, 0)

* subItems = new ListViewItem.ListViewSubItem[]
* {new ListViewItem.ListViewSubItem(item, "Directory"),
* new ListViewItem.ListViewSubItem(item, dir.LastAccessTime.ToShortDateString())};
* set subItems = type System.Windows.Forms.ListViewItem(
* new type System.Windows.Forms.ListViewItem+ListViewSubItem(item, "Directory"),
* new type System.Windows.Forms.ListViewItem+ListViewSubItem(item, dir::LastAccessTime::ToShortDateString)
)

try
invoke item::SubItems::AddRange(subItems)
catch
continue
end-try

invoke listView1::Items::Add(item)
end-perform

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: C# to VC

Hi Neil, should be something like:

set subItems to table of type ListViewItem.ListViewSubItem
(new ListViewItem.ListViewSubItem(item, "Directory"),
new ListViewItem.ListViewSubItem(item, dir.LastAccessTime.ToShortDateString()))

...or probably just:
set subItems to table of
(new ListViewItem.ListViewSubItem(item, "Directory"),
new ListViewItem.ListViewSubItem(item, dir.LastAccessTime.ToShortDateString()))

I'm not in a position to try this out right now, so can't guarantee this is 100% correct...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: C# to VC

Hi Robert,

Thanks but thats not it, its something like below but I just cant get the syntax right:-

set subItems = new type System.Windows.Forms.ListViewItem+ListViewSubItem[](
new type System.Windows.Forms.ListViewItem+ListViewSubItem(item, "Directory"),
new type System.Windows.Forms.ListViewItem+ListViewSubItem(item, , dir::LastAccessTime::ToShortDateString)
)
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: C# to VC

If ListViewSubItem is a nested class of ListViewItem then maybe (assuming ilusing"System.Windows.Forms" is in effect):

set subItems to table of type ListViewItem+ListViewSubItem
(new ListViewItem+ListViewSubItem(item, "Directory"),
new ListViewItem+ListViewSubItem(item, dir.LastAccessTime.ToShortDateString()))
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: C# to VC

Hi, Im now getting error below in the IDE

Severity Code Description Project File Line
Error COBCH1624 : Cannot implicitly convert ListViewItem+ListViewSubItem[] to type System.Windows.Forms.ListViewItem+ListViewSubItem occurs any.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: C# to VC

Strange, would if be possible for you to send me the project (robert.sales@microfocus.com) and I'll have a look...
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: C# to VC

i can do but wont it get blocked?
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.