Autor Beitrag
Ccenter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

Win7
C#
BeitragVerfasst: Fr 26.03.10 22:30 
Moin,
ich habe meinem Panel ein contextmenustrip hinzugefügt. Dieses wird allerdings nur gezeigt, wenn man einen Rechtsklick darauf ausführt. Ich möchte den strip allerdings auch mit der linken Taste sichbar machen. Ich habe mir erst gedacht, dass man ein Sendkey Befehl in das Clickevent des Panels setzen könnte aber da muss es doch noch etwas einfacheres geben wie z.B. bei Buttons "Button1.PerformClick" oder?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19340
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 26.03.10 23:18 
Warum zeigst du den ContextMenuStrip nicht einfach mit Show an? :gruebel:
Ccenter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

Win7
C#
BeitragVerfasst: Sa 27.03.10 16:37 
Ok, hätte man drauf kommen können :D
Allerdings hab ich schon gleich das 2. Problem: Der strip erscheint nämlich in der linken oberen Bildschirmecke. ich hab das jetzt folgendermaßen versucht, jedoch gebt es keine location Methode:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
private Point Curser;
private void panel4_Click(object sender, EventArgs e)
        {
            strip2.Show();           
            Point mousepos2 = Control.MousePosition;
            mousepos2.Offset(Curser.X, Curser.Y);
            
        }


Damit hätte ich dann schonmal die Curserposition ermittelt. Aber wie bekomme ich jetzt den contextmenustrip dahin?
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Sa 27.03.10 17:04 
Die Lösung ist in jaenickes Beitrag verlinkt ;) ...

Was du aber mit dem Offset vorhast, ist mir unklar.

_________________
>λ=
Ccenter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

Win7
C#
BeitragVerfasst: So 28.03.10 13:39 
Ok danke, habs.

ausblenden C#-Quelltext
1:
2:
3:
 
Point mousepos2 = Control.MousePosition;
strip2.Show(mousepos2);