KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

DataGrid in KF.NET

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Wed Jun 14, 2006 8:55 pm    Post subject: DataGrid in KF.NET Reply with quote

This thread was created so we can learn how to create a DataGrid in KF.NET. It has a steep learning curve and a lot of .NET users complained about it (which is why DataGridView was created in .NET 2.0). Since KF.NET is currently using 1.1, DataGridView is not supported at this time.

These are the summarized steps to make DataGrid work in KF.NET :

1.) Create a DataTable
2.) Add Columns and Rows to it
3.) Add the DataTable to a DataSet
4.) Use the DataSet.SaveXml method to save the schema and data

later...

5.) Create a DataSet
6.) Use the DataSet.LoadXml to "restore" or "reload" the DataSet to its former glory
7.) Continue using it in your script - save it again

List of items to accomplish when using DataGrid :

1.) Multi-select unique cells on grid
2.) Highlight unique cells (BackColor?)
3.) Create row headers

Let's get to work! Wink
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Jun 14, 2006 9:08 pm    Post subject: Reply with quote

well...
your steps are bit wrong but I forgive you as I think shawn told you the steps.
here is a working script.
everyone can view how simple it is, ONCE you find out what affects what.
and as I got the basics, propably we get more ppl figuring it out.
think this stuff will really blow our heads!

Code:

$sys = CreateObject("Kixforms.System")
$form = $sys.form
$grid = $form.Controls.Add($sys.DataGrid)
$grid.Dock = $sys.DockStyle_Fill
;$source = $sys.DataSet
;$table = $source.Tables.Add($sys.DataTable)
$table = $sys.DataTable
"not here"
$col = $table.columns.Add($sys.DataColumn)
"not here"
;$style = $grid.col
$col.DataType = "text"
$col.ColumnName = "Name"
$col = $table.columns.Add($sys.DataColumn)
$col.DataType = "number"
$col.ColumnName = "PostCount"
$col = $table.columns.Add($sys.DataColumn)
$col.DataType = "date"
$col.ColumnName = "Registered"
Dim $data[4]
$data[0] = "Shawn","1680","22 Feb 2003"
$data[1] = "Jochen","1042","05 Mar 2003"
$data[2] = "Lonkero","920","13 Mar 2003"
$data[3] = "Sealeopard","397","05 Mar 2003"
$data[4] = "Bonji","379","10 Mar 2003"
For Each $person in $data
 $row = $table.Rows.Add($table.NewRow)
 For $i=0 to UBound($person)
  $item = $row.Item($i)
  $item.value = $person[$i]
 Next
Next
$grid.datasource = $table

$form.Show

While $form.Visible
 $=Execute($sys.Application.DoEvents)
Loop

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Jun 14, 2006 9:40 pm    Post subject: Reply with quote

here is another example showing 2 tables side by side:
Code:

$sys = CreateObject("Kixforms.System")
$form = $sys.form
$form.Width = 580
For $grids=0 to 1
 $grid = $form.Controls.Add($sys.DataGrid)
 $grid.Dock = IIf($grids,$sys.DockStyle_Right,$sys.DockStyle_Left)
 $grid.width = $form.ClientWidth/2
 $table = $sys.DataTable
 $col = $table.columns.Add($sys.DataColumn)
 $col.DataType = "text"
 $col.ColumnName = "Name"
 $col = $table.columns.Add($sys.DataColumn)
 $col.DataType = "number"
 $col.ColumnName = "PostCount"
 $col = $table.columns.Add($sys.DataColumn)
 $col.DataType = "date"
 $col.ColumnName = "Registered"
 Dim $data[4]
 $data[0] = "Shawn","1680","22 Feb 2003"
 $data[1] = "Jochen","1042","05 Mar 2003"
 $data[2] = "Lonkero","920","13 Mar 2003"
 $data[3] = "Sealeopard","397","05 Mar 2003"
 $data[4] = "Bonji","379","10 Mar 2003"
 For Each $person in $data
  $row = $table.Rows.Add($table.NewRow)
  For $i=0 to UBound($person)
   $item = $row.Item($i)
   $item.value = $person[$i]
  Next
 Next
 $grid.datasource = $table
Next
$form.Show

While $form.Visible
 $=Execute($sys.Application.DoEvents)
Loop

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Jun 14, 2006 9:52 pm    Post subject: Reply with quote

one more.
this one got me to thinking.
it almost seems like the table supports datasets.
so, one can infinitely sink the data deeper and deeper.

also a note on the original "steps"
if one wants to dig out the lines for the providers... CSV provider might be the best to start with.
writexml works but as it's not humanreadable (I said human, not geek) it's not the best example, imho.
Code:

$sys = CreateObject("Kixforms.System")
$form = $sys.form
$form.Width = 580
$grid = $form.Controls.Add($sys.DataGrid)
$grid.Dock = $sys.DockStyle_Fill
$grid.captionText = "Example dataset with 8 tables"
$source = $sys.DataSet
For $tables=0 to 7
 $table = $source.Tables.Add($sys.DataTable)
 $table.TableName = "the table #" + (1 + $tables)
 $col = $table.columns.Add($sys.DataColumn)
 $col.DataType = "text"
 $col.ColumnName = "Name"
 $col = $table.columns.Add($sys.DataColumn)
 $col.DataType = "number"
 $col.ColumnName = "PostCount"
 $col = $table.columns.Add($sys.DataColumn)
 $col.DataType = "date"
 $col.ColumnName = "Registered"
 Dim $data[4]
 $data[0] = "Shawn","1680","22 Feb 2003"
 $data[1] = "Jochen","1042","05 Mar 2003"
 $data[2] = "Lonkero","920","13 Mar 2003"
 $data[3] = "Sealeopard","397","05 Mar 2003"
 $data[4] = "Bonji","379","10 Mar 2003"
 For Each $person in $data
  $row = $table.Rows.Add($table.NewRow)
  For $i=0 to UBound($person)
   $item = $row.Item($i)
   $item.value = $person[$i]
  Next
 Next
 $grid.datasource = $source
Next
$form.Show

While $form.Visible
 $=Execute($sys.Application.DoEvents)
Loop


ps, have I ever expressed my dislike of xml Wink

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jun 15, 2006 1:17 am    Post subject: Reply with quote

lol, jooel - only YOU could have done all that in like - one page of kixtart code - nice.
Back to top
View user's profile Send private message
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Thu Jun 15, 2006 5:14 pm    Post subject: Reply with quote

I've been working on this, but can't figure out a way to highlight cells. Is it even possible?
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Thu Jun 15, 2006 6:41 pm    Post subject: Reply with quote

you mean scripted highlight?
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Fri Jun 16, 2006 11:31 pm    Post subject: Reply with quote

it doesn't look like it's possible to highlight in DataGrid. I may need to resort back to KF Classic.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Sat Jun 17, 2006 12:58 pm    Post subject: Reply with quote

yes, the control is very limited, sadly.
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group