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

Auto Complete

 
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Jul 04, 2008 2:57 am    Post subject: Auto Complete Reply with quote

I have been asked to create an "auto-complete" text box.

I am completely at a loss on where to begin...

This is for user lookup in AD, and I can populate an array with all of the users names with no problem ... Think my array would look like this....

$Array[0,X] = UserID (SamAccountName)
$Array[1,X] = Last Name (Surname)
$Array[2,X] = First Name (GivenName)
$Array[3,X] = Mail (SMTP: entry)

So how would I create a text box that can scan the array while a user types and do autocomplete at the same time.

Oh and they want to be able to type either the UserID or the Last name.

Thanks.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Jul 04, 2008 5:30 pm    Post subject: Reply with quote

Sounds like an interesting (read: challenging) project. Do you mean an autocomplete textbox or an autocomplete *combobox* ?
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Jul 04, 2008 6:21 pm    Post subject: Reply with quote

Here's kinda a first stab. Crude I guess:

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.Width = 640
$Form.Height = 480

$TextBox = $Form.TextBox()
$TextBox.Center
$TextBox.OnKeyUp = "TextBox_KeyUp()"

$Array = "Adam", "John", "Bill", "William", "Sally", "Sue", "Ray", "Raymond",
"James", "Johnny", "Betty", "Fred"

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

Exit 0

Function TextBox_KeyUp()

 $Len = Len($TextBox.Text)
 $Pos = $TextBox.SelectionStart

 $KeyCode = $System.EventArgs.KeyCode
 If $KeyCode = 8
  Return
 Endif

 For $i = 0 To UBound($Array)
  If $Len > 0
   If Left($Array[$i],$Len) = $TextBox.Text
    $TextBox.Text = $Array[$i]
    $TextBox.SelectionStart = $Pos
    $TextBox.SelectionLength = 999
   Endif
  Endif
 Next

EndFunction
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Jul 04, 2008 7:00 pm    Post subject: Reply with quote

TextBox / ComboBox whatever works the easiest.

I will go over your sample later and see what / how it does it's magic.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Sat Jul 05, 2008 12:09 am    Post subject: Reply with quote

Ok, pretty cool, but what are doing with the KeyCode stuff, why are we looking for "8" specifically?

And I think you were correct when you stated to do it with a combo box. I am working on that now. Oh and I did this in the wrong forum, I am developing in .Net

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
AJ83
KiXforms Follower
KiXforms Follower


Joined: 14 Jun 2007
Posts: 16

PostPosted: Mon Jul 07, 2008 3:52 pm    Post subject: Reply with quote

How about this piece of kixforms.net ?

Code:
Break On
$System = CreateObject("KiXforms.System")

;endregion

;region Form Creation
;Warning: It is recommended that changes inside this region be handled using the ScriptForm Designer.
;When working with the ScriptForm designer this region and any changes within may be overwritten.

;~~< Form1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Form1 = $System.Form()
$Form1.Size = $System.Size(278, 111)
$Form1.Text = "Form1"
;~~< ComboBox1 >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ComboBox1 = $Form1.Controls.Add($System.ComboBox())
$ComboBox1.Size = $System.Size(215, 21)
$ComboBox1.SelectedIndex = -1
$ComboBox1.Location = $System.Point(12, 38)
$ComboBox1.TabIndex = 0
$ComboBox1.KeyPress = "AutoComplete( $$ComboBox1 )"
$ComboBox1.Keydown = "AutoCompleteBackspace( $$ComboBox1 )"
;endregion

;region Event Loop
fillarray()

$Form1.Show
While $Form1.Visible
   $=Execute($System.Application.DoEvents)
Loop

;endregion

;endregion
Function fillarray()
$array = Split("apenhoofd,aap,apenstreek,aapinjehaar",",")
EndFunction

Function AutoCompleteBackspace( $object )
Dim $text,$len,$keychar

$KeyChar = $object.KeyDownEventArgs.KeyCode

If $ComboBox1.items.count = 0
   Return
EndIf

If $keychar = 8
   $text = $combobox1.text
   $len = Len($text)
   $ComboBox1.text = Left($text,($len-1))
EndIf

EndFunction

;~~< GoComboBox >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function AutoComplete( $object )
Dim $text,$len
$text = $ComboBox1.text
$len = Len($text)
;$ComboBox1.DroppedDown = 0

$ComboBox1.items.clear
If $ComboBox1.text <> ""
   For $i = 0 to UBound($array)
      If $text = Left($array[$i],$len)
         $ComboBox1.items.add($array[$i])
         $ComboBox1.Text = $array[$i]
         $ComboBox1.selectionstart = $len
         $ComboBox1.selectionlength = Len(Right($array[$i],Len($array[$i]) - $len))
      EndIf
   Next
   ;$ComboBox1.DroppedDown = -1
   $ComboBox1.selectionstart = $len
EndIf
EndFunction


Needed the functionality myself, worked on it for a while, but this seems to work quite nice Smile

It is possible to let it display all the possibility`s in the dropdown, but sometimes a value gets selected by accident, wich screws up your typing ( try this by unremming the droppeddown property commands ).
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Jul 07, 2008 4:42 pm    Post subject: Reply with quote

Thanks, I will take stab with this as well and tweak according to my needs.
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting 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