odinborson
Programmer
Hi, I'm using the TableLayoutPanel and wondering if there is a method to get the row and collum clicked when my TableLayoutPanel gets a mousedown event. For instance with a DataGrid you can say something like
DataGrid.HitTestInfo info = dataGrid.HitTest(e.X, e.Y);
and info will contain the row and collumn. The OnCellPaint method has a TableLayoutCellPaintEventArgs argument which contains the row and collumn, but the mousedown just has a MouseEventArgs giving the x and y position.
Another strange thing is happening, and maybe someone can explain it to me. I need a horizontal scroll bar to appear so I set AutoScroll to be true. The TableLayoutPanel computes my collumn widths in a complex way because some collums are set to percent, some too absolute sizes. Sometimes the width sizes are computed a little too big and horizontal scrollbar appears. If AutoScroll is off TableLayoutPanel will compute the collumn widths right. To get my scrollbars to appear right, I have to write this code after setting up the rows and collumns (at runtime)
AutoScroll = false
AutoScroll = true;
AutoScroll = true;
HScroll = false;
looks absolutely crazy huh? But suppose I take out the erronius looking Autoscroll assignments, and just set HScroll to false, a horizontal scrollbar appears at the bottom, but widthwise everything fits so the scroller is useless and does not work. Setting HorizontalScroll to false doesn't hide it. If I remove all the lines I get a horixontal scroll bar. And if I do other simpler combinations I can get the horizontal scrollbar to refuse to appear but then all of a sudden the vertical scrollbar is buggy. When you move the scroll thingy down it goes back to the top when the mouse is released (but right clicking the scrollbar and clicking bottom and top still works). Seems I need the above code
DataGrid.HitTestInfo info = dataGrid.HitTest(e.X, e.Y);
and info will contain the row and collumn. The OnCellPaint method has a TableLayoutCellPaintEventArgs argument which contains the row and collumn, but the mousedown just has a MouseEventArgs giving the x and y position.
Another strange thing is happening, and maybe someone can explain it to me. I need a horizontal scroll bar to appear so I set AutoScroll to be true. The TableLayoutPanel computes my collumn widths in a complex way because some collums are set to percent, some too absolute sizes. Sometimes the width sizes are computed a little too big and horizontal scrollbar appears. If AutoScroll is off TableLayoutPanel will compute the collumn widths right. To get my scrollbars to appear right, I have to write this code after setting up the rows and collumns (at runtime)
AutoScroll = false
AutoScroll = true;
AutoScroll = true;
HScroll = false;
looks absolutely crazy huh? But suppose I take out the erronius looking Autoscroll assignments, and just set HScroll to false, a horizontal scrollbar appears at the bottom, but widthwise everything fits so the scroller is useless and does not work. Setting HorizontalScroll to false doesn't hide it. If I remove all the lines I get a horixontal scroll bar. And if I do other simpler combinations I can get the horizontal scrollbar to refuse to appear but then all of a sudden the vertical scrollbar is buggy. When you move the scroll thingy down it goes back to the top when the mouse is released (but right clicking the scrollbar and clicking bottom and top still works). Seems I need the above code