CPF Listview ohne Rahmen

tareq

Grünschnabel
Hallo

möchte nur wissen wie man ein ListView ohne Border erstellen kann ohne das Listview andocken zu müssen.
Habe ein ListView das halt nur über die Hälfte der Form geht. Bei diesem möchte ich gerne das der untere Rahmen verdeckt wird.

Gruss Tareq
 
Hi

ich dachte durch das CPF im Title wird klar das ich das listview im Compact Framework einsetzte.
Da gibt es leider das Property BorderStyle nicht. Mein erster Gedanke ging aber auch in die Richtung.

Nach langen googlen habe ich aber eine Lösung gefunden :

Code:
public Form1()
        {
            InitializeComponent();

            ShowBorder(listView1.Handle, false);
        }

        private void ShowBorder(IntPtr handle, bool bShow)
        {
            int style = GetWindowLong(handle, GWL_STYLE);
            if (bShow)
            {
                style |= WS_BORDER;
            }
            else
            {
                style &= ~WS_BORDER;
            }
            SetWindowLong(handle, GWL_STYLE, style);
            SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
        }

        const int GWL_STYLE = -16;
        const int WS_BORDER = 0x00800000;
        const int SWP_NOSIZE = 0x1;
        const int SWP_NOMOVE = 0x2;
        const int SWP_FRAMECHANGED = 0x20;

        [DllImport("coredll.dll")]
        private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

        [DllImport("coredll.dll")]
        private extern static void SetWindowLong(IntPtr hwnd, int nIndex, int dwNewLong);

        [DllImport("coredll.dll")]
        private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int uflags);

Meiner Meinung nach sehr umfangreich um eigentlich etwas simples zu erreichen. Da muss sich Microsoft mal etwas einfallen lassen.:)
 

Neue Beiträge

Zurück