This paper presents a control scheme for virtual synchronous generators (VSGs) in PV inverters, designed to enhance grid frequency and voltage. Through the skillful management of active and reactive power, this control scheme enables PV inverters to interact seamlessly with the main grid in response to grid events, including voltage and frequency fluctuations. The VSG controller is implemented using Matlab Simulink, and its effectiveness is rigorously assessed under various scenarios in a case study involves a 50 kVA rated PV inverter, a 50 kW rated PV system, and a 220 V grid phase voltage. In conditions of low power generation from the PV system (solar radiation of 200 W/m²) and high load power (120 kW and 37.5 kVAr), the load voltage drops to 202.4 V. The VSG controller successfully raises the grid voltage by 17.6 V, stabilizing it at 220 V. Conversely, in scenarios of high PV power generation (solar radiation of 1000 W/m²) and low load power (20 kW and 7.5 kVAr), the grid voltage surges by 10 V, reaching 230 V. The proposed control strategy adeptly fine-tunes the voltage, ultimately stabilizing at 220 V. Additionally, when the frequency deviates within ±0.4 Hz from the nominal frequency of 50 Hz, the proposed control effectively restores the frequency to its nominal value.