ASP.NET Web Controls >> Datagrid resizing

by vMike » Thu, 21 Aug 2003 07:08:26 GMT

You could use the following, but I should note that sometimes the width of
one cell effects the other cells so you may need to play with this.

Public Sub Display2_ItemDataBound(sender As Object, e As
DataGridItemEventArgs)
'this is if you are in edit mode
if display2.EditItemIndex > -1 then
if display2.EditItemIndex = e.item.itemindex then
ctype(e.Item.Cells(3).controls(0),textbox).Width = Unit.Pixel(35)
ctype(e.Item.Cells(6).controls(0),textbox).Width = Unit.Pixel(45)
ctype(e.Item.Cells(7).controls(0),textbox).Width = Unit.Pixel(35)
ctype(e.Item.Cells(8).controls(0),textbox).Width = Unit.Pixel(45)
ctype(e.Item.Cells(9).controls(0),textbox).Width = Unit.Pixel(225)
else
e.item.visible = false

end if
'this is if you are not
ctype(e.Item.Cells(3),tablecell).Width = Unit.Pixel(35)

end if

End Sub
"yop" < XXXX@XXXXX.COM > wrote in message
news:0e4001c3672b$0d4e0f20$ XXXX@XXXXX.COM ...
> All
>
> How do you stop the datagrid auto resizing?
> I have a grid in a page and if the recordset returns the
> 12 records which is the setting for the paging then the
> grid is sized spot on in the page and each row is the
> correct size.
> If the recordset only returns 2 records then the grid is
> stretched to fix the window and the rows are miles too
> wide.
>
> How do I stop this
>
> Thanks



Similar Threads

1. Datagrid resizing.

You could try setting the size of each column explicitly.  
Something like:

<asp:TemplateColumn headertext="Category">
  <ItemTemplate>
  </ItemTemplate>
  <HeaderStyle Width=150px />
</asp:TemplateColumn>


2. Datagrid: resize font in Pager row - ASP.NET Web Controls

3. Problems with datagrid resizing

Hi,

I have a user control which has amongst other things a datagrid and
underneath this a command button. The problem is that the datagrid is
being resized depending on the data that is bound to it which can make
the grid overlap the command button.

Is there a way of either stopping the grid from resizing, or
repositioning the command button so that it is always at a fixed
offset below the bottom of the grid....


Thanks in advance, 


Richard.

4. How to avoid DataGrid resizing - Asp.Net

5. WebForm DataGrid Resizing using Mouse

Hi,
 In a ASP.NET page I have a DataGrid Control populated with some data.
 I want to resize the DataGrid columns using mouse.
 That is, when I move the cursor to the edge of a column, the cursor must change to "Size WE" cursor. So that I can drag the column to my preferred size.
 Can any one help me by giving the code.
Thanks & Regards, 
John
-- 
MTS-Software Engineer,
Sharp Software Development India, Pvt. Ltd.,
Unit 5, Level 3, Innovator, ITPL,
Whitefield Road,
Bangalore 560 066,
INDIA
www.sharp.co.in
Phone:91 - 0 - 94483 22577

6. Disable Datagrid Resizing

7. How to make table inside datagrid resize?

I have form with datagrid control. I bind dataview object to datasource 
property of the datagrid to populate it with data.

My question is how can I make columns and rows of the table inside datagrid 
resize when form itself resizes. I set anchor property properly so datagrid 
control itself DOES resize when I resize form, but table inside datagrid 
control doesn't.

Can anyone give me a hint?

Thanks

8. Datagrid Resize - .NET Windows Forms