Fix radgrid height with paging - radgrid

How to fix the size of radgrid irrespective of records.
I set the paging with pagesize = 5.
When radgrid has 5 rows its height will be ok.
If the grid has 2 rows its fits to the 2 rows height.
How to fix the radgrid height.
I think you got my problem.
I'm doing like this in page_load
radgrid.Height=Unit.Pixel(200);
Hi can anyone answer my question..?

In the Databound() event handler, check for the number of records.
int c = RadGrid1.Items.Count()
Then try your:
RadGrid1.Height = Unit.Pixel( Whatever you want ) * c;

set the scroll height instead of setting the height. This makes sure that the whole data area height is maintained.
RadGrid1.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(200);
This article may help as well.
http://www.telerik.com/help/aspnet-ajax/grid-height-vs-scrollheight.html

Related

VBA resize table to fit to page's width

I want to resize a table to fit to the pages width via VBA code.
I have tried it with the following code:
mytable.PreferredWidthType = wdPreferredWidthPercent
mytable.PreferredWidth = 100
Can anyone tell me how I can resize the table to the page size? My first page has an edge of 2 centimeters and because of this the table jumps to page 2.
Thanks in advance!
You could try the AutoFitBehavior property of the table.
mytable.AutoFitBehavior = wdAutoFitWindow
AutoFitBehavior

problem with fitting datagridview height according to the content

I have a datagridview whose styling is kept as follows
dgvCreatinine.AutoGenerateColumns = False
dgvCreatinine.AutoSize = False
dgvCreatinine.AutoResizeRows()
dgvCreatinine.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
dgvCreatinine.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders)
dgvCreatinine.DataSource = dtTemp
It is appearing as shown in the attached image
As you can see the gridview is not resizing to the content along row wise. Could someone tell me how this can be accomplished? Thanks in advance.
You can just set the height of the entire control using this formula
DataGridViewHeight = HeaderHeight + NumberOfRows * RowHeight
Code:
dgvCreatinine.Height =
dgvCreatinine.ColumnHeadersHeight _
+ dgvCreatinine.Rows.OfType(Of DataGridViewRow).First().Height * dgvCreatinine.Rows.Count()
This works, but could use some tweaking. For example, there may be a better way to get the row height. And you may also need to add a pixel or two depending on borders. Also, if you have an underlying DataSource, you could get the rows count from it.
That code should be called whenever a row is added or removed, or DataBindings are updated etc.

How to change the width of an item in a listview?

I have a winforms application with a listview that shows 6 items. The problem is that each item's width is too long so the user has to scroll to the right to see all of each item.
How can I shorten the width of each rectangle for each item to match the width of the data inside the item/rectangle???
Thank you
Use this code:
ListviewName.View = View.Details
ListviewName.Columns.Clear()
ListviewName.Columns.Add("Columnn1", CInt(ListviewName.Width / divide))
add all your column.
divide value is depends on how many column in your Listview, but that's if you want all of your column size is equal.

Datagrid autoheight + lazy loading

I have a Dojo Datagrid which has 10 columns and about 400 records of data... it doesn't seem like that much but it is very very slow to scroll...
I have another Datagrid which has some 5k records and it scrolls faster. The only difference between the two is that for one I am specifying the height in pixels and have autoheight turned off...
For the smaller one, I couldn't use height = 100% to fill up its parent div because for some reason it doesn't like a percent height and doesn't even render the grid if I specify a percent height - I have to give it in pixels... if I use autoheight = true, then it fills up its parent div which is what I want but then it loads ALL data in the grid at once and so it doesn't do any lazy loading of the data.
Any ideas how to achieve lazy loading and still be able to use autoheight = true (or be able to expand the grid so that it always fills up the height of its parent div)?
Thanks
autoHeight can be set to a numeric value, which will define the maximum number of rows to display

The control or subform control is too large for this location on resize

I have a simple form in Access 2003. The form has a List control and a button. I wanted to make the list to resize with the form (only vertically) while the button remains at the bottom right of the List. I'm using the following code on the form's resize event.
list.Height = Me.InsideHeight - list.Top - 200
commandButton.Top = list.Height + list.Top + 50
This works fine as I resize the form, until the form height gets to a certain height. Then I get this error;
Run-time error '2100':
The control or subform control is too large for this location
This error is occurring at the line where I'm assigning the commandButton.Top. If I remove this line then the list height changes fine. I don't have any subforms in the form.
Does anyone know why this is happening?
Thanks
I think it is because you need to resize the detail section of the form first.
Try changing the code to
Me.Section(0).Height = Me.InsideHeight
list.Height = Me.InsideHeight - list.Top - 200
commandButton.Top = list.Height + list.Top + 50
Came by here (as many have) with the same problem and then realised my issue. Be mindful when resizing a control to a larger size with regard to the order of setting properties.
I would recommend setting the TOP and LEFT positions before HEIGHT and WIDTH.
Although my final sized control should have fitted OK once resized, I had originally tried setting the WIDTH first which attempted to enlarge the control exceeding the width of the form. My application threw the 2100 error at that point. I really hope this helps someone! Also, don't forget to set dimensions in TWIPS which is set as INCHESS x 1440 (or CM x 566.9291), ie: .Width = 10 * 566.9291 to set a control width to 10cm.
I get this same error if I set the width to greater the 31680.
With a little more research, I notice MS Access only allows a form width to be 22" wide. 22" = 31680 TWIPS.
So my workaround solutions it to add a check:
If newWidth > 31680 Then newWidth = 31680