DataGrid size

Max width and Height

Page 1 of 1

9 Replies - 5830 Views - Last Post: 29 October 2008 - 01:54 AM Rate Topic: -----

#1 whoisit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 15-October 08

DataGrid size

Posted 22 October 2008 - 11:26 PM

Hi again :angry:

My DataGrid is working fine and doing everythng it should. :)
What I want now is when an image is loaded into column 1 it can not be any larger than 100

I've tried various concoctions of code and none work here is my latest idea :crazy:
If pbPreview.Width > 100 Then DataGridView1.AutoSize = False
						DataGridView1.Columns(0).Width = 100

It doesn't work, (No surprise there then!) plus there is no .Height member to Columns or Rows.

So what is the way to make sure that any image loaded, can only be 100 x 100 max?

Graham

Is This A Good Question/Topic? 0
  • +

Replies To: DataGrid size

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 179
  • Posts: 1,600
  • Joined: 17-April 07

Re: DataGrid size

Posted 22 October 2008 - 11:42 PM

i think you didn't watch the rows method i am sure rows have the height method and more over set the image column layout to stretch
i think this will solve the problem
Was This Post Helpful? 0
  • +
  • -

#3 whoisit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 15-October 08

Re: DataGrid size

Posted 23 October 2008 - 04:21 AM

View Postthava, on 22 Oct, 2008 - 11:42 PM, said:

i think you didn't watch the rows method i am sure rows have the height method and more over set the image column layout to stretch
i think this will solve the problem


Here's the latest this works for the width but not the height

		  If pbPreview.Width > 100 Then DataGridView1.AutoSize = False
						Dim column As DataGridViewColumn = DataGridView1.Columns(0)
						column.Width = 100
						If pbPreview.Height > 100 Then DataGridView1.AutoSize = False
						Dim row As DataGridViewRow = DataGridView1.Rows(0)
						row.Height = 100


This post has been edited by whoisit: 23 October 2008 - 04:33 AM

Was This Post Helpful? 0
  • +
  • -

#4 whoisit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 15-October 08

Re: DataGrid size

Posted 27 October 2008 - 05:21 AM

Hi,

Sorry if this is bumping?

Just wondering if any one has figured out an answer yet? that's if there is one?

Graham
Was This Post Helpful? 0
  • +
  • -

#5 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: DataGrid size

Posted 27 October 2008 - 11:56 AM

Have you tried setting the DataGridViewImageColumn.ImageLayout to stretch as mentioned earlier? Select the grid, right click, select edit columns, select the image column, change the ImageLayout property to Stretch. Then set the DataGridView.RowTemplate.Height to 100.
Was This Post Helpful? 0
  • +
  • -

#6 whoisit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 15-October 08

Re: DataGrid size

Posted 27 October 2008 - 12:22 PM

View Postmagicmonkey, on 27 Oct, 2008 - 11:56 AM, said:

Have you tried setting the DataGridViewImageColumn.ImageLayout to stretch as mentioned earlier? Select the grid, right click, select edit columns, select the image column, change the ImageLayout property to Stretch. Then set the DataGridView.RowTemplate.Height to 100.



Hi Magic,

Thanks for that but still not working, it distorts all the images (stretches) that are less than 100, but still lets those greater than 100 appear at their original height.
This program is to load smileys I know that most are less than 100 x 100 but you need to allow for the end user to load something totally different!
Plus I think the ability to keep the rows height to 100 should be just as easy to keep the columns to 100, it's like a challenge now. :D

Graham
Was This Post Helpful? 0
  • +
  • -

#7 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: DataGrid size

Posted 27 October 2008 - 01:03 PM

The RowTemplate.Height=100 will set each rows height to 100, may have to set it before you add the rows, then you just got to play with the imagestyle, to get the non distorted scaling your looking for. There are many options that won't distort the image.
Was This Post Helpful? 1
  • +
  • -

#8 whoisit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 15-October 08

Re: DataGrid size

Posted 28 October 2008 - 11:22 AM

View Postmagicmonkey, on 27 Oct, 2008 - 01:03 PM, said:

The RowTemplate.Height=100 will set each rows height to 100, may have to set it before you add the rows, then you just got to play with the imagestyle, to get the non distorted scaling your looking for. There are many options that won't distort the image.


Thanks for taking the time to answer Magic,

So basically I need to come at this from a different angle,
Set each row and col to 100 before anything loads, then when images do load, if they're > 100 in width or height, then rescale the image to fit.?

Graham
Was This Post Helpful? 0
  • +
  • -

#9 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: DataGrid size

Posted 28 October 2008 - 02:40 PM

I did a test, set the ImageLayout to Zoom and it will scale the image to fit without changing the images aspect ratio. So that with RowTemplate.Height = 100 should give you what you want.
Was This Post Helpful? 1
  • +
  • -

#10 whoisit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 15-October 08

Re: DataGrid size

Posted 29 October 2008 - 01:54 AM

View Postmagicmonkey, on 28 Oct, 2008 - 02:40 PM, said:

I did a test, set the ImageLayout to Zoom and it will scale the image to fit without changing the images aspect ratio. So that with RowTemplate.Height = 100 should give you what you want.



Thanks Magic for all your help,

I've got it working to a standard that I'm happy with and as good as Gridview will allow.

Graham
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1