How to connect 2 PCs at the same monitor or display

There are at least two methods:

The first method of course is to use a graphic display that has 2 video inputs (2 VGA, 2 DVI ,or 1 DVI and 1 VGA).
Take the example of a display that has both VGA and DVI input, and the two computers have graphics cards with different outputs (the first PC with VGA output, the second PC with DVI output).
You can then connect the 2 cables (VGA and DVI) for 2 PCs simultaneously with the same monitor. Then you press the button that changes the "display source" (VGA or DVI) depending on the PC you want to use (see).
Of course this does not solve the problem of having to use double keyboards  and double mouse!
The second method involves the use of a Switch KVM (Keyboard, Video, Mouse), a device that connects a keyboard, a mouse and only a single display, but which has the double output cables ( or triple, etc..) tha connect the PCs to be controlled. The PCs should not be too far apart as the cables are quite short!
They are marketed both mechanical and electronic KVM switch, with different features (VGA, DVI, PS2 or USB keyboard, etc..) also KVM Switch exist for more than two PCs.

In the first case, the test was done for example with a Samsung SyncMaster 2243WM that has one entry VGA and one DVI, and it works!
In the second case currently I use a KVM switch (mechanical) that allows the use of one keyboard (PS2), one mouse (PS2) and a single display (VGA) connected to 2 PCs.