PDA

View Full Version : listbox editable text fields


JokerMartini
02-13-2012, 04:56 PM
Is there a dotnet item that allows users to double click and edit the displayed text in that cell?

I know there are work arounds such as creating a popup dialog with an edit text field and all that, it's just annoying to do and I was hoping dotnet had something more simple.


(
try (destroyDialog ::rlListBox) catch()
rollout rlListBox "Drop Down List"
(
dotNetControl lbItems "System.Windows.Forms.ListBox" height:100 ItemHeight:10

on lbItems SelectionChangeCommitted e do
(
print "here it goes"
fnUpdateList()
)

on lbItems doubleClicked itm do
(
lbItems.text = lbItems.items["cool"]
)

on rlListBox open do
(
lbItems.items.addrange #("nice","nice","nice","nice")
)
)
createDialog rlListBox
)

JasonB
02-13-2012, 05:33 PM
I used this: http://forums.cgsociety.org/showthread.php?p=4832734#post4832734

And modified it to get the bounds of the cell being clicked -- and replaced it with a .net textbox. The textbox currently excepts esc or enter and then does some work to update the object model.

fn subItemAtMousePos lv =
(
-- this has the potential to miss selecting an item that could cause an error... might as well ignore it and
-- let the user just double click again.
try
(
-- get mouseposition on screen
local pos = lv.mousePosition -- screen position
local posScreen = [pos.x, pos.y] -- need the screen position for placement of new edittext

-- get dialog (specifically the LV) position information
pos = lv.PointToClient pos
local posDialog = [pos.x, pos.y]

-- get information for the listview item & subitem
local li = lv.getItemAt pos.x pos.y
local si = li.getSubItemAt pos.x pos.y

-- Get the bounding box position.
local posBounds = [si.Bounds.X, si.Bounds.Y-2]

-- do the math.
posFinal = ((posScreen - posDialog) + posBounds)

-- Get the indices for listview item index and the subitem index.
local idxs = #( li.index , (li.subitems.indexof si) )

--// debug print
print lv.Items.item[idxs[1]].subitems.item[idxs[2]].text

::g_tempEditTextBoxInfo = lv.Items.item[idxs[1]].subitems.item[idxs[2]].text -- I needed to add a global that the second rollout can read on create
createDialog NetTextBoxTest style:#(#style_sunkenedge) pos:posFinal modal:true -- make the dialog look integrated.
)
)
catch()
)

denisT
02-13-2012, 06:06 PM
Is there a dotnet item that allows users to double click and edit the displayed text in that cell?

it's pain in the a$$ really. that's why for this kind of interface solution i moved from listview to datagrid.

JokerMartini
02-13-2012, 06:35 PM
Do you have any examples of that which I could check out and see for reference.

denisT
02-13-2012, 09:10 PM
Do you have any examples of that which I could check out and see for reference.

you can search for samples on this forum... DataGridView... i posted some snippets

CGTalk Moderation
02-13-2012, 09:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.