How to provide a gui interface for modify a row's text in a ListView Topic is solved
How to provide a gui interface for modify a row's text in a ListView
How to provide a gui interface for modify a row's text in a ListView, or even it is possible if doubleclick the row will become editable
Re: How to provide a gui interface for modify a row's text in a ListView
You could have the event for a double-click go to a function that opens a separate small GUI on top of the main one that is nothing but an Edit control and maybe OK and Cancel buttons. Its initial contents are whatever the ListView cell contained. Then when the user hits Enter or clicks an OK button on that GUI, it goes away and the ListView cell is updated with the edited contents of the popup GUI’s Edit control.
Alternatively, the Edit control doesn’t need to be in a separate GUI but could be on the same GUI above or below the ListView.
Alternatively, the Edit control doesn’t need to be in a separate GUI but could be on the same GUI above or below the ListView.
Re: How to provide a gui interface for modify a row's text in a ListView
An example. Modifications can be made via double-clicking or the right-click context menu.
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance
gMain := Gui(, 'gMainTitle')
gMain.OnEvent('Close', (*) => ExitApp())
gMain.lv := gMain.Add('ListView', 'Grid Sort', ['Col1', 'Col2'])
gMain.lv.OnEvent('ContextMenu', gMain_lv_ContextMenu)
gMain.lv.OnEvent('DoubleClick', gMain_lv_DoubleClick)
loop 3
gMain.lv.Add(, 'row' A_Index '_valueCol1', 'row' A_Index '_valueCol2')
loop 2
gMain.lv.ModifyCol(A_Index, 'AutoHdr')
;==============================================
gEdit := Gui(, 'gEditTitle')
gEdit.edit_col1 := gEdit.Add('Edit')
gEdit.edit_col2 := gEdit.Add('Edit')
gEdit.btn_Ok := gEdit.Add('Button', 'Default', 'Ok')
gEdit.btn_ok.OnEvent('Click', gEdit_btn_ok_Click)
gEdit.btn_Cancel := gEdit.Add('Button',, 'Cancel')
gEdit.btn_Cancel.OnEvent('Click', gEdit_Close)
gEdit.OnEvent('Close', gEdit_Close)
gMain.Show()
;==============================================
gMain_lv_ContextMenu(ctrlObj, item, isRightClick, x, y)
{
MouseGetPos(,,, &mouseOverClassNN)
if item = 0 || InStr(mouseOverClassNN, 'SysHeader')
return
ctxMenu := Menu()
ctxMenu.Add('Edit', gEdit_Show.Bind(item))
ctxMenu.Show(x, y)
}
;==============================================
gMain_lv_DoubleClick(ctrlObj, item, *)
{
if item = 0
return
gEdit_Show(item)
}
;==============================================
gEdit_btn_ok_Click(*)
{
gMain.lv.Modify(gMain.lv_rowSelected,, gEdit.edit_col1.Value, gEdit.edit_col2.Value)
loop 2
gMain.lv.ModifyCol(A_Index, 'AutoHdr')
gEdit_Close()
}
;==============================================
gEdit_Show(item, *)
{
gMain.Opt('+Disabled')
gEdit.Opt('+Owner' gMain.hwnd)
gEdit.edit_col1.Value := gMain.lv.GetText(item, 1)
gEdit.edit_col2.Value := gMain.lv.GetText(item, 2)
gMain.lv_rowSelected := item
gEdit.Show()
}
;==============================================
gEdit_Close(*)
{
gMain.Opt('-Disabled')
gEdit.Hide()
}
Re: How to provide a gui interface for modify a row's text in a ListView Topic is solved
There is also this script by just me.
LVICE_XXS - LV in-cell editing minimal version
viewtopic.php?f=83&t=94046
LVICE_XXS - LV in-cell editing minimal version
viewtopic.php?f=83&t=94046
Re: How to provide a gui interface for modify a row's text in a ListView
Thanks for the detailed guidanceboiler wrote: ↑30 Apr 2024, 05:35You could have the event for a double-click go to a function that opens a separate small GUI on top of the main one that is nothing but an Edit control and maybe OK and Cancel buttons. Its initial contents are whatever the ListView cell contained. Then when the user hits Enter or clicks an OK button on that GUI, it goes away and the ListView cell is updated with the edited contents of the popup GUI’s Edit control.
Alternatively, the Edit control doesn’t need to be in a separate GUI but could be on the same GUI above or below the ListView.
Re: How to provide a gui interface for modify a row's text in a ListView
Thanks for providing the exampleXMCQCX wrote: ↑30 Apr 2024, 14:28An example. Modifications can be made via double-clicking or the right-click context menu.Code: Select all
#Requires AutoHotkey v2.0 #SingleInstance gMain := Gui(, 'gMainTitle') gMain.OnEvent('Close', (*) => ExitApp()) gMain.lv := gMain.Add('ListView', 'Grid Sort', ['Col1', 'Col2']) gMain.lv.OnEvent('ContextMenu', gMain_lv_ContextMenu) gMain.lv.OnEvent('DoubleClick', gMain_lv_DoubleClick) loop 3 gMain.lv.Add(, 'row' A_Index '_valueCol1', 'row' A_Index '_valueCol2') loop 2 gMain.lv.ModifyCol(A_Index, 'AutoHdr') ;============================================== gEdit := Gui(, 'gEditTitle') gEdit.edit_col1 := gEdit.Add('Edit') gEdit.edit_col2 := gEdit.Add('Edit') gEdit.btn_Ok := gEdit.Add('Button', 'Default', 'Ok') gEdit.btn_ok.OnEvent('Click', gEdit_btn_ok_Click) gEdit.btn_Cancel := gEdit.Add('Button',, 'Cancel') gEdit.btn_Cancel.OnEvent('Click', gEdit_Close) gEdit.OnEvent('Close', gEdit_Close) gMain.Show() ;============================================== gMain_lv_ContextMenu(ctrlObj, item, isRightClick, x, y) { MouseGetPos(,,, &mouseOverClassNN) if item = 0 || InStr(mouseOverClassNN, 'SysHeader') return ctxMenu := Menu() ctxMenu.Add('Edit', gEdit_Show.Bind(item)) ctxMenu.Show(x, y) } ;============================================== gMain_lv_DoubleClick(ctrlObj, item, *) { if item = 0 return gEdit_Show(item) } ;============================================== gEdit_btn_ok_Click(*) { gMain.lv.Modify(gMain.lv_rowSelected,, gEdit.edit_col1.Value, gEdit.edit_col2.Value) loop 2 gMain.lv.ModifyCol(A_Index, 'AutoHdr') gEdit_Close() } ;============================================== gEdit_Show(item, *) { gMain.Opt('+Disabled') gEdit.Opt('+Owner' gMain.hwnd) gEdit.edit_col1.Value := gMain.lv.GetText(item, 1) gEdit.edit_col2.Value := gMain.lv.GetText(item, 2) gMain.lv_rowSelected := item gEdit.Show() } ;============================================== gEdit_Close(*) { gMain.Opt('-Disabled') gEdit.Hide() }
Re: How to provide a gui interface for modify a row's text in a ListView
Thanks for sharing the code, "in-cell editing" that's really amazing.XMCQCX wrote: ↑30 Apr 2024, 15:31There is also this script by just me.
LVICE_XXS - LV in-cell editing minimal version
viewtopic.php?f=83&t=94046
Who is online
Users browsing this forum: No registered users and 22 guests