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

Embed ComboBox in ListView

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


Joined: 10 Aug 2005
Posts: 50

PostPosted: Sat May 06, 2006 6:10 pm    Post subject: Embed ComboBox in ListView Reply with quote

Is it posible to embed a one control inside another? For example a combobox inside a listview item. Kixforms designer seems to allow this for the property grid. Is it a listview or datagrid? Can I make it so the control is always visible - rather then only when the cell/item is selected?
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun May 07, 2006 12:15 am    Post subject: Reply with quote

Benny and I experimented with embedding a combo box into a DataGrid - using raw dotnet (like vb.net) the results are "satisfactory" but not great - using kf.net, the results were not great either. One of the problems we encountered was that the combo box doesn't like being resized into the cell. It never seemed to want to fit quite right.

Anyway, other than that - cant think of any ready-to-go thing that would serve this purpose. Let me research some more.
Back to top
View user's profile Send private message
mercury
KiXforms Regular
KiXforms Regular


Joined: 10 Aug 2005
Posts: 50

PostPosted: Sun May 07, 2006 12:30 am    Post subject: Reply with quote

What I was trying to do was create a form that looked a bit like the excel auto-filter feature. I wanted the comboboxes to be dynamically linked to the relative comlumn width below. Using the first row of the listview would have made it very neat.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun May 07, 2006 2:15 am    Post subject: Reply with quote

well, lets work together to see if we can accomplish something - let me take the first stab - may need to add some new properties/methods to kf.net.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun May 07, 2006 3:07 am    Post subject: Reply with quote

Download the latest .net development build (I had to add some stuff) ...

I found this article on the web:

http://www.dotnet247.com/247reference/msgs/14/71810.aspx

Its very crude and it doesn't give you what you want, but its a start ... here is the code ...

Code:

Break On

$System = CreateObject("Kixforms.System")

$Form = $System.Form()
$Form.Text = "Form1"
$Form.Width = 640
$Form.Height = 480

$ListView = $Form.Controls.Add($System.ListView())
$ListView.Dock = $System.DockStyle_Fill
$ListView.View = $System.View_Details
$ListView.MouseUp = "ListView_MouseUp()"

$Column1 = $ListView.Columns.Add($System.ColumnHeader())
$Column2 = $ListView.Columns.Add($System.ColumnHeader())
$Column3 = $ListView.Columns.Add($System.ColumnHeader())

For $i = 1 To 10
 $ListViewItem = $ListView.Items.Add($System.ListViewItem("Item$i"))
 $ListViewSubItem = $ListViewItem.SubItems.Add($System.ListViewSubItem("Subitem1"))
 $ListViewSubItem = $ListViewItem.SubItems.Add($System.ListViewSubItem("Subitem2"))
Next

$ComboBox = $Form.Controls.Add($System.ComboBox())
$ComboBox.BringToFront
$ComboBox.Hide
$ComboBox.KeyUp = "ComboBox_KeyUp()"
$ComboBox.SelectedIndexChanged = "ComboBox_SelectedIndexChanged()"

$= $ComboBox.Items.Add("Value1")
$= $ComboBox.Items.Add("Value2")
$= $ComboBox.Items.Add("Value3")

$Form.Center
$Form.Show

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

Exit 0

Function ListView_MouseUp

 ; Get the item that was clicked

 $e = $System.EventArgs

 $MyItem = $ListView.GetItemAt($e.X, $e.Y);

 ; Check if an actual item was clicked
 If $MyItem

  ; Get the bounds of the item clicked

  $ClickedItem = $MyItem.Bounds

  ; Adjust the top and left of the control

  $ClickedItem.X = $ClickedItem.X + $ListView.Left
  $ClickedItem.Y = $ClickedItem.Y + $ListView.Top

  ; Set combobox bounds to match calculation

  $ComboBox.Bounds = $ClickedItem;

  ;// Set the default text for the combobox to be
  ;// the clicked item's text

  $ComboBox.Text = $MyItem.Text;

  ;// Show the combobox and make sure it is on top
  ;// and give focus to the combobox

  $ComboBox.Visible = 1
  $ComboBox.BringToFront()
  $ComboBox.Focus()

 Endif

EndFunction

Function ComboBox_KeyUp()

 $e = $System.EventArgs

 ;// Check if user types "ESC"

 If $e.KeyCode = $System.Keys_Escape
  ;// Hide the combobox
  $ComboBox.Visible = 0;
 Endif

EndFunction

Function ComboBox_SelectedIndexChanged()

 ; Set text of listview item

 $MyItem.Text = $ComboBox.Text
 $ComboBox.Text = ""

 ; Hide the combobox

 $ComboBox.Visible = 0

EndFunction
Back to top
View user's profile Send private message
mercury
KiXforms Regular
KiXforms Regular


Joined: 10 Aug 2005
Posts: 50

PostPosted: Sun May 07, 2006 11:00 am    Post subject: Reply with quote

Thanks Shawn, I will have a play.
Back to top
View user's profile Send private message
mercury
KiXforms Regular
KiXforms Regular


Joined: 10 Aug 2005
Posts: 50

PostPosted: Sun May 07, 2006 12:17 pm    Post subject: Reply with quote

Hi Shawn,

This is excellent and I would definately find a use for it, but from what I gather about the listview control, subitems are not selectable?

Here is an image from Excel showing what I'm after:



When you select an item from the drop down, only rows containing that entry in the relevant column will be visible.

The goal here for me is to create a log viewer

Is Listview the best control for this?
Back to top
View user's profile Send private message
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