DataGridView: last column can be made smaller but not bigger

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a DataGridView control where the user can resize the columns. The
control is embedded inside a Panel. When clicking on and dragging the column
seperator to the right of the rightmost column, I can make the column smaller
when I move it to the left. If I try to move it to the right however, my
cursor is halted against the edge of the control. So the column can't be made
bigger.

This can be reproduced in the sample at
http://msdn2.microsoft.com/en-us/library/1x64c23x.aspx by clicking
Customer->View Orders in the main form and doing it on the table that
appears. In that sample, it is possible to make the last column bigger again
by making the whole window bigger, until its length is more than the total
length of the columns, creating an open space between the columns and the
edge of the window. Then the right seperator of the rightmost column can be
dragged freely, up until the edge of the window.

However, this trick isn't practical in my own control, since the control is
too small and the total column length too long.

Is there some standard way to make it behave like the list view in Explorer,
where you can resize past the border of the window?

Kind regards,
Raf
 
Hi there,

I dont know off the top of my head. I had a quick look just now and i see
your problem. I would have thought some of the border/column properties etc
would have allowed an easy override of this restriction. Obviously resizing
is possible but it looks like you might to bake your own. Perhaps something
like

OnGridMouseDown()
if (cursor == widthchange cursor) and (mousepos=gridrightedgepos) then
lastcolwidth +=1;

??

Richard
 
I feared as much :-) Thanks for the reply, I'll try something like that when
I revisit the problem. If I find a concrete solution I'll post it back here.

Raf
 
Hello - I ran into the same issue but it's easily resolved. Inherant to the
DataGridView is the ability to have it autosize it's columns just by
double-clicking on the column header. To do so, position the mouse to the
right side of the column you want to resize and double click when you get the
column width change cursor.

Mike
 
Thanks, I hadn't thought of that. I'll probably still try to implement the
resizing by dragging, because the current behaviour seems counterintuitive to
me, but at least I have a workaround now :-)
 
Back
Top