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

GV.KIX - the GridView Sample code ...

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Sep 24, 2004 11:40 am    Post subject: GV.KIX - the GridView Sample code ... Reply with quote

as requestested so many times now and I am quite tired of mailing this thing :

Please note that this will only work with build 46 and above AND that the functionality is subject to change!

Code:
break on

$TITLE = "KF: Gridview Designer"
$AUTHOR = "Shawn Tassie"
$VERSION = "1.0"

$NOREFCELL = "Please select a reference cell"

$System = CreateObject("Kixtart.System")

$form = $system.form()
$form.size = 640,400
$form.text = $TITLE
$form.font = $system.font("Verdana",10)

$menu = $system.mainmenu()

$FileMenu = $Menu.MenuItems.Add("File")

$EditMenu = $Menu.MenuItems.Add("Edit")

$DeleteRowMenu = $EditMenu.MenuItems.Add("Delete")
$DeleteRowMenu.OnClick = "DeleteRowClick()"

$ViewMenu = $Menu.MenuItems.Add("View")
$InsertMenu = $Menu.MenuItems.Add("Insert")

$FormatMenu = $Menu.MenuItems.Add("Format")

$FormatCellMenu = $FormatMenu.MenuItems.Add("Cell")

$FormatCellForeColorMenu = $FormatCellMenu.MenuItems.Add("Text Color...")
$FormatCellForeColorMenu.OnClick = "FormatForeColor(0)"
$FormatCellBackColorMenu = $FormatCellMenu.MenuItems.Add("Background Color...")
$FormatCellBackColorMenu.OnClick = "FormatBackColor(0)"

$FormatRowMenu = $FormatMenu.MenuItems.Add("Row")

$FormatRowForeColorMenu = $FormatRowMenu.MenuItems.Add("Text Color...")
$FormatRowForeColorMenu.OnClick = "FormatForeColor(1)"
$FormatRowBackColorMenu = $FormatRowMenu.MenuItems.Add("Background Color...")
$FormatRowBackColorMenu.OnClick = "FormatBackColor(1)"

$FormatSheetMenu = $FormatMenu.MenuItems.Add("Sheet")

$FormatSheetForeColorMenu = $FormatSheetMenu.MenuItems.Add("Text Color...")
$FormatSheetForeColorMenu.OnClick = "FormatForeColor(2)"
$FormatSheetBackColorMenu = $FormatSheetMenu.MenuItems.Add("Background Color...")
$FormatSheetBackColorMenu.OnClick = "FormatBackColor(2)"

$ExitMenu = $FileMenu.MenuItems.Add("Exit")
$ExitMenu.OnClick = "ExitClick()"

$InsertRowMenu = $InsertMenu.MenuItems.Add("Row")
$InsertRowMenu.OnClick = "InsertRowClick()"

$Form.Menu = $Menu

$StatusBar = $Form.StatusBar()

$EditBox = $Form.TextBox()
$EditBox.Height = 25
$EditBox.Dock = "Top"

$gridview = $form.gridview()

$gridview.dock = "fill"
$gridview.oncellchanged = "CellChanged()"

$gridview.columns.count = 6
$gridview.rows.count = 20

$gridview.columns(0).width = 18
$gridview.columns(1).width = 200
$gridview.columns(2).width = 160
$gridview.columns(3).width = 90
$gridview.columns(4).width = 75
$gridview.columns(5).width = 75

$gridview.columns(1).text = "Component Name"
$gridview.columns(2).text = "Company"
$gridview.columns(3).text = "Unit Price"
$gridview.columns(4).text = "Quantity"
$gridview.columns(5).text = "Amount"

$gridview.cells(0,1).text = "Kixforms GridView Control"
$gridview.cells(0,2).text = "www.kixforms.org"
$gridview.cells(0,3).text = "0"
$gridview.cells(0,4).text = "1"

$gridview.cells(1,1).text = "Spread V6.0"
$gridview.cells(1,2).text = "FarPoint Technologies"
$gridview.cells(1,3).text = "592"
$gridview.cells(1,4).text = "1"

$gridview.cells(2,1).text = "#Grid V2.0"
$gridview.cells(2,2).text = "Data Dynamics"
$gridview.cells(2,3).text = "291"
$gridview.cells(2,4).text = "1"

$gridview.cells(3,1).text = "VSFlexGrid Pro V8.0 Q4 2003"
$gridview.cells(3,2).text = "ComponentOne"
$gridview.cells(3,3).text = "389"
$gridview.cells(3,4).text = "1"

$gridview.cells(4,1).text = "True DBGrid Pro"
$gridview.cells(4,2).text = "ComponentOne"
$gridview.cells(4,3).text = "389"
$gridview.cells(4,4).text = "1"

$gridview.cells(5,1).text = "itGrid"
$gridview.cells(5,2).text = "it-partners.com"
$gridview.cells(5,3).text = "579"
$gridview.cells(5,4).text = "1"

$gridview.cells(6,1).text = "Janus GridEX"
$gridview.cells(6,2).text = "Janus Systems"
$gridview.cells(6,3).text = "320"
$gridview.cells(6,4).text = "1"

$gridview.cells(7,1).text = "ExpressQuantumGrid Suite V4.5.1"
$gridview.cells(7,2).text = "Developer Express"
$gridview.cells(7,3).text = "341"
$gridview.cells(7,4).text = "1"

for $i = 0 to $gridview.rows.count - 1
 $gridview.cells($i,5).text = $gridview.cells($i,3).text
next

$form.center
$form.show

While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 1

Function InsertRowClick()

 If $GridView.SelectedRow

  $Row = $GridView.Rows.Insert($GridView.SelectedRow.Index)

 Else

  $= $System.MessageBox.Show("Please select a reference cell",$TITLE)

 Endif

EndFunction

Function DeleteRowClick()

 If $GridView.SelectedRow

  $GridView.Rows.Remove($GridView.SelectedRow.Index)

 Else

  $= $System.MessageBox.Show("Please select a reference cell",$TITLE)

 Endif

EndFunction

;; formatting functions ...

Function FormatCellBackColor()

 Dim $cd

 If $GridView.SelectedCell

  $cd = $System.ColorDialog()

  $cd.Color = $GridView.SelectedCell.BackColor

  If $cd.ShowDialog = $System.DialogResult.Ok

   $GridView.SelectedCell.BackColor = $cd.Color

  Endif

 Endif

EndFunction

Function FormatBackColor($Object)

 Dim $cd

 Select
  Case $Object = 0 ;; Cell
   $Object = $GridView.SelectedCell
  Case $Object = 1 ;; Row
   $Object = $GridView.SelectedRow
  Case $Object = 2 ;; Sheet
   $Object = $GridView
  Case 1
   Return
 EndSelect

 If $Object

  $cd = $System.ColorDialog()

  $cd.Color = $Object.BackColor

  If $cd.ShowDialog = $System.DialogResult.Ok

   $Object.BackColor = $cd.Color

  Endif

 Else

  $= $System.MessageBox.Show($NOREFCELL,$TITLE)

 Endif

EndFunction

Function FormatForeColor($Object)

 Dim $cd

 Select
  Case $Object = 0 ;; Cell
   $Object = $GridView.SelectedCell
  Case $Object = 1 ;; Row
   $Object = $GridView.SelectedRow
  Case $Object = 2 ;; Sheet
   $Object = $GridView
  Case 1
   Return
 EndSelect

 If $Object

  $cd = $System.ColorDialog()

  $cd.Color = $Object.ForeColor

  If $cd.ShowDialog = $System.DialogResult.Ok

   $Object.ForeColor = $cd.Color

  Endif

 Else

  $= $System.MessageBox.Show($NOREFCELL,$TITLE)

 Endif

EndFunction

Function FormatSheetBackColor()

 Dim $cd

 $cd = $System.ColorDialog()

 $cd.Color = $GridView.BackColor

 If $cd.ShowDialog = $System.DialogResult.Ok

  $GridView.BackColor = $cd.Color

 Endif

EndFunction

Function ExitClick()

 quit()

EndFunction

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> 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