Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 532

Table editing from iLogic

$
0
0

By Adam Nagy

You may have lots of data that you would like to make editable for the user. If it can be organized into a table then you could simply use a Form with a DataGridView on it. There is an article on providing custom dialogs from iLogic: http://adndevblog.typepad.com/manufacturing/2013/06/use-vbnet-dialog-in-ilogic.html

This will be the same, but here we will expose the DataGridView which is placed on the Form so you can take advantage of all its functionality: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview(v=vs.100).aspx  

This is how you can use it from an iLogic Rule

Imports System.Windows.Forms
AddReference "C:\temp\MyTableForm.dll" 

Using mf As New MyTableForm.MyForm
  mf.Text = "Get Data"	
  Dim dgv As DataGridView = mf.dgvTable' set columns
  Dim c1 As Integer = dgv.Columns.Add("MyColumn1", "MyColumnHeader1")
  Dim c2 As Integer = dgv.Columns.Add("MyColumn2", "MyColumnHeader2")' add two rows
  Dim r1 As Integer = dgv.Rows.Add()
  Dim r2 As Integer = dgv.Rows.Add()' disable sorting
  dgv.Columns(c1).SortMode = DataGridViewColumnSortMode.NotSortable 
  dgv.Columns(c2).SortMode = DataGridViewColumnSortMode.NotSortable' set cell data
  dgv.Rows(r1).Cells(1).Value = "test1"
  dgv.Rows(r2).Cells(1).Value = "test2"' make one of them read-only
  dgv.Rows(r2).Cells(1).ReadOnly = True' show the dialog
  If mf.ShowDialog() = DialogResult.OK Then
    MsgBox(dgv.Rows(0).Cells(0).Value, MsgBoxStyle.Information, "Results")
  End If
End Using

The result:

MyTableForm

Here is the source code of the VB.NET 2010 project: Download MyTableForm_2013-11-18
The compiled dll is also part of the zip file in folder "MyTableForm\MyTableForm\bin\Release".


Viewing all articles
Browse latest Browse all 532

Trending Articles