Load
Introduction
Warning
We recommend that you use either ListViewContentXML
or ListViewContentJson
instead of our custom system which is old and outdated.
a. Required configuration
To use the following methods, you need to use the version 1.7 or higher of LeoCorpLibrary, and put this at the top of your code file:
C#
using LeoCorpLibrary;
VB
Imports LeoCorpLibrary
b. How it works
To understand how the system works, read save system.
- The system is going to read the file
- The system is going to separate the elements
- The system is going to separate the columns
- From each "row", it will generate a
ListViewItem
. - Then it loads the
ListViewItem
inside the specified ListView.
Functions
a. ListViewContentCustom
This function is available in version 1.7 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ❌ |
.NET 5 | ✔ | ❌ |
.NET Core 3.1 | ✔ | ❌ |
.NET Framework 4.5 | ✔ | ❌ |
The ListViewContentCustom()
method enables you to load the content of a ListView from a file. We recommend that you se these following parameters for your ListView:
Details
vue modeFullRowSelect
= true
There is two variations of the method:
Variation 1
LeoCorpLibrary.Load.ListViewContentCustom(ListView listView1, string filePath) {...}
Value | Argument | Description |
---|---|---|
ListView | listView | The ListView to load the content to |
string | filePath | The file location where the content is |
Variation 2
LeoCorpLibrary.Load.ListViewContentCustom(ListView listView1, string filePath, string itemSplit, string columnSplit) {...}
Value | Argument | Description |
---|---|---|
ListView | listView | ListView to load the content to |
string | filePath | The file location where the content is |
string | itemSplit | The element separator |
string | columnSplit | The column separator |
Here's an example of usage:
C#
// Variation 1
LeoCorpLibrary.Load.ListViewContentCustom(listView1, @"C:\content.txt");
// Variation 2
LeoCorpLibrary.Load.ListViewContentCustom(listView1, @"C:\content.txt", "/*E*/", "/*C*/");
VB
' Variation 1
LeoCorpLibrary.Load.ListViewContentCustom(ListView1, "C:/content.txt")
' Variation 2
LeoCorpLibrary.Load.ListViewContentCustom(ListVew1, "C:/content.txt", "/*E*/", "/*C*/")
Note
In the examples, you might noticed that instead of simply writing Load.ListViewContentCustom
, it is written LeoCorpLibrary.Load.ListViewContentCustom
. This because of a conflict with Load
which is an event in Windows Forms.
b. ListViewContentXML
This function is available in version 2.7 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ❌ |
.NET 5 | ✔ | ❌ |
.NET Core 3.1 | ✔ | ❌ |
.NET Framework 4.5 | ✔ | ❌ |
The ListViewContentXML()
method allows you to load a XML file that contains a listview's content. We recommend that you use these following parameters for your ListView:
Details
vue modeFullRowSelect
= true
It has two arguments:
Value | Argument | Description |
---|---|---|
ListView | listView | ListView where it's content needs to be saved |
string | filePath | File location where to save the ListView's content |
Here's an example of usage:
C#
LeoCorpLibrary.Load.ListViewContentXML(listView1, "C:/test.xml");
VB
LeoCorpLibrary.Load.ListViewContentXML(listView1, "C:/test.xml")
Input:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ArrayOfString>
<string>Test1</string>
<string>Test2</string>
<string>Test3</string>
</ArrayOfString>
<ArrayOfString>
<string>Test4</string>
<string>Test5</string>
<string>Test6</string>
</ArrayOfString>
<ArrayOfString>
<string>Test7</string>
<string>Test7</string>
<string>Test8</string>
</ArrayOfString>
</ArrayOfArrayOfString>
Expected Output:
Column 1 | Column 2 | Column 3 |
---|---|---|
Test 1 | Test 2 | Test 3 |
Test 4 | Test 5 | Test 6 |
Test 8 | Test 8 | Test 9 |
c. ListViewContentJSON
This function is available in version 2.7 and higher.
Compatibility
Frameworks | LeoCorpLibrary | LeoCorpLibrary.Core |
---|---|---|
.NET 6 | ✔ | ❌ |
.NET 5 | ✔ | ❌ |
.NET Core 3.1 | ✔ | ❌ |
.NET Framework 4.5 | ❌ | ❌ |
The ListViewContentJSON()
method allows you to load a listview's content from a JSON file. We recommend that you use these following parameters for your ListView:
Details
vue modeFullRowSelect
= true
It has two arguments:
Value | Argument | Description |
---|---|---|
ListView | listView | ListView where it's content needs to be saved |
string | filePath | File location where to save the ListView's content |
Here's an example of usage:
C#
LeoCorpLibrary.Load.ListViewContentJSON(listView1, "C:/test.json");
VB
LeoCorpLibrary.Load.ListViewContentJSON(listView1, "C:/test.json")
Input:
[
[
"Test1",
"Test2",
"Test3"
],
[
"Test4",
"Test5",
"Test6"
],
[
"Test7",
"Test7",
"Test8"
]
]
Expected Output:
Column 1 | Column 2 | Column 3 |
---|---|---|
Test 1 | Test 2 | Test 3 |
Test 4 | Test 5 | Test 6 |
Test 8 | Test 8 | Test 9 |