Hi,
Has anyone implemented .Net DataGridView with LANSA yet?
If yes, could I have a simple sample please?
I appreciate your kind advice!
Best Regards,
Megumi Sawada
.Net DataGridView with LANSA
-
MegumiSawada
- Posts: 80
- Joined: Tue Mar 22, 2016 1:45 pm
- Location: Tokyo, Japan
-
MegumiSawada
- Posts: 80
- Joined: Tue Mar 22, 2016 1:45 pm
- Location: Tokyo, Japan
Re: .Net DataGridView with LANSA
Hi,
I would like to show data on LANSA form by using DataGridView from .Net.
What I woud like to do is as follows:
- showing data by passing SELECT statement to .Net component
- adding a row to DataGridView (I've confirmed I can add a column)
- passing data to DataSource of DataGrdiView from LANSA
I will be delighted if you kindly provide some samples to show how to acheive these.
I appreciate you kind advice
Best Regards,
Megumi Sawada
I would like to show data on LANSA form by using DataGridView from .Net.
What I woud like to do is as follows:
- showing data by passing SELECT statement to .Net component
- adding a row to DataGridView (I've confirmed I can add a column)
- passing data to DataSource of DataGrdiView from LANSA
I will be delighted if you kindly provide some samples to show how to acheive these.
I appreciate you kind advice
Best Regards,
Megumi Sawada
Re: .Net DataGridView with LANSA
Megumi,
The easiest way to populate your DataGridView would be to use a DataTable as a data source.
https://msdn.microsoft.com/en-us/librar ... .110).aspx
You may be able to instantiate the DataTable and populate it purely using RDML, but it would be much easier if you create a .NET user control that wraps the DataGridView, and just expose an AddRow method that you can call from your RDML to add new rows.
The .NET code to create and add a row the Data Table, and bind it to the DataGridView looks like this:
You may be able to achieve the same by enrolling the System.Data.dll assembly and then do the same as above from RDML.
If you decide to create your own wrapper, you would need to place the resulting assembly (.dll) in the partition execute folder.
The easiest way to populate your DataGridView would be to use a DataTable as a data source.
https://msdn.microsoft.com/en-us/librar ... .110).aspx
You may be able to instantiate the DataTable and populate it purely using RDML, but it would be much easier if you create a .NET user control that wraps the DataGridView, and just expose an AddRow method that you can call from your RDML to add new rows.
The .NET code to create and add a row the Data Table, and bind it to the DataGridView looks like this:
Code: Select all
// Create a new DataTable
var dataTable = new System.Data.DataTable();
dataTable.Columns.Add("FullName");
dataTable.Columns.Add("Title");
// Create a new row in the DataTable
var row = dataTable.NewRow();
row["FullName"] = "John Watson";
row["Title"] = "Mr";
dataTable.Rows.Add(row);
// Bind the DataGridView to the DataTable
this.dataGridView.DataSource = dataTable;
If you decide to create your own wrapper, you would need to place the resulting assembly (.dll) in the partition execute folder.