local miConvertTo=createMenuItem(AddressList)
miConvertTo.Caption=translate('Convert into header with address')
miConvertTo.OnClick=function(s)
  local i
  for i=0,AddressList.Count-1 do
    if AddressList[i].Selected then
      AddressList[i].IsGroupHeader=true
      AddressList[i].IsAddressGroupHeader=true
    end
  end
end

AddressList.PopupMenu.Items.insert(MainForm.miTableStateBase.MenuIndex, miConvertTo)

local miConvertFrom=createMenuItem(AddressList)
miConvertFrom.Caption=translate('Convert from header into record')
miConvertFrom.OnClick=function(s)
  local i
  for i=0,AddressList.Count-1 do
    if AddressList[i].Selected then
      AddressList[i].IsAddressGroupHeader=false
      AddressList[i].IsGroupHeader=false
    end
  end
end

AddressList.PopupMenu.Items.insert(MainForm.miTableStateBase.MenuIndex, miConvertFrom)

local oldOnPopup=AddressList.PopupMenu.OnPopup

AddressList.PopupMenu.OnPopup=function(s)
  if oldOnPopup then
    oldOnPopup(s)
  end

  miConvertTo.Visible=AddressList.SelectedRecord and not AddressList.SelectedRecord.IsGroupHeader
  miConvertFrom.Visible=AddressList.SelectedRecord and AddressList.SelectedRecord.IsGroupHeader
end