when I want to enter to open my path, the click event is activated
31 Replies
You should totally use Dapper.
i suggest Entity Framework
anyway im not sure what ur talking about, can u provide more details?
what is this?
So I have a form that has 3 buttons, each button sits in the groupbox a panel with various buttons that are created by hand in the code. I want a path to open when I press enter. So, with the help of the arrows, I want to go through those buttons in the panel and when I press enter, that path will open. I managed to implement, I say, but when I press enter, the click event is activated. When I press enter, I want the path to the file to open. The file paths are stored in the database.
It allows you to map SQL query results to objects
But the more modern approach is using EF Core
what click event, where is it in ur code?
it's a separate method
well, hard to help without knowing what method is it calling
https://paste.ofcode.org/apFHHdSg7hg88uu8LJK6vR
i put the method
this is the click event
when I press enter on the button, what should appear when I press click appears
Button_Click ?
yes
but I don't want this to appear when I press enter
was the button focused when u pressed enter?
yes
selectedIndex = 0;
booksPhilosophy[selectedIndex].Focus();
what do u want to appear when u press enter then?
to run the path
so you want the button to call button_click method if clicked by mouse, and run the path if pressed enter on it?
yess
why not just create a different button
idk if this is possible, might need to look it up
button for ??
to run the path
in the panel there are several buttons that would represent the cover of a book and not just one button
probably what I want is impossible but I don't understand why
well try something like this
in ur BooksInEnglish_KeyDown method
looks the same as before
private void BooksInEnglish_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Right)
{
NavigateButtons(1);
}
else if (e.KeyCode == Keys.Left)
{
NavigateButtons(-1);
}
else if (e.KeyCode == Keys.Enter && buttonPsychology1.Focused)
{
OpenBookPath();
}
}
}
did it work?
nope :Smadge:
i don't know what to do
can you help me what to do about this
well uh i cant test winform apps but try this instead of the click event https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.onmouseclick?view=windowsdesktop-8.0#system-windows-forms-control-onmouseclick(system-windows-forms-mouseeventargs)
Control.OnMouseClick(MouseEventArgs) Method (System.Windows.Forms)
Raises the MouseClick event.
or MouseDown
@Ale did this work?
nope
I managed in the end, I made a separate button that deals with this
and it s work new
Ok sick, still wanna see if there is a way to do what you wanted but will do so in my own free time
if you manage to solve it, please tell me how you did it
Will do