trying to fix a bug where i cant get the click event on a buttom
hello, i have an issue with a windows form program, i have a panel where buttons gonna be placed, and i have a TableLayoutPanel that component gonna be the layout to the buttons "styles" i mean
only that, and the problem is the next
the button stay behind the "style panel" and it goes untouchable, i tried a couple of things but i cant reach the buttom click event
50 Replies
you can subscribe to the event before adding to the layout panel?
i dont catch u, my main languaje is spanish, but can u explain pls
i mean you can access the buttons OnClick event before it goes "untouchable". So add your event handle logic for that event first. Then add the button to the layoutpanel
lemme try
it didnt work
Whats the issue? error?
no
lemme share some pics
sure
this it the code
sorry for the spanish comments lol
lol
no problem
the buttomlayout is red
so the buttom is behind
now
if i comment the next line
it goes black
OH
meaning the buttom can be reached by the mause
so i need the layout but when i put it in i cant click the buttom haha
how big is "buttonLayout"
it also has a Click event... I think you are clicking that instead. So actually may want to handle that instead
yeah i tried it
but i didnt work
O.o
kinda crazy
let me read the code again lol
oke
so let me get this right.
There is a LayoutPanel, and inside that layout panel there are 6 Buttons. In each button there is a LayoutPanel. In that LayoutPanel there is an Image and a Label. You want it so that if you click anywhere in the red it will raise the Button's Click event?
more or less
panelContenedor have the 6 buttoms
and exactly u wrotte every button has a panel with an image and a text
and yes and want to click and do whaterever
okay, you need to handle all controls inside of the button. This includes the image, label, layoutpanel, etc with the same event handler. I personally would make a custom control
u mean instead to use a panel and a button
only a buttom?
I mean, if you really must have all the controls intact you must handle all their click events
let me code something up
oke
reading
ok lemme try it
you can also make a recursive method to go through all controls (children) and subscribe to their events, to make things easier
i think it didnt work
nothing at all?
oh i see
i think it works
lol, which is it?
k i need to change some things waitme a moment
sure
LMAO
IT WORKS
I very much would use the OnPaint event to just draw the image and text on the button
k watch ]
or place a generated image on the button
before, on the onclick event i was getting the button information
so now the other controlls calls the same fuct too
so i fixed and it works
good job
ur the best ❤️
aw shucks
3 hours wasted on that thing hahaha
Oh damn
:kiss:
ty
you're welcome and good luck
diner time finally
FOOD