Hallo,
Here ya go,
Er is al in het nieuwere framework een mogelijkheid,... ik denk in de oudere frameworks niet,... nu kan het zo,...
Code: Console.CursorLeft = 10;
Console.CursorTop = 10;
En het kan ook zo,...
Code: using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
private const int STD_OUTPUT_HANDLE = -11;
private static int hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
static void Main(string[] args)
{
for (int i = 1; i < 19; i++)
{
SetPos((short)(i * 4), (short)i);
Console.Write("****");
int j = 19 - i;
SetPos((short) (j * 4), (short)i);
Console.Write("****");
}
Console.ReadKey();
}
static void SetPos(short x, short y)
{
COORD pos;
pos.x = x;
pos.y = y;
SetConsoleCursorPosition(hConsoleHandle, pos);
}
[StructLayout(LayoutKind.Sequential)]
struct COORD
{
public short x;
public short y;
}
[DllImport("kernel32.dll", EntryPoint="GetStdHandle", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", EntryPoint="SetConsoleCursorPosition", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
private static extern int SetConsoleCursorPosition(int hConsoleOutput, COORD dwCursorPosition);
}
}
Groeten |