Welcome Guest Search | Active Topics | Members | Log In | Register

Center images Options
Tomas
Posted: Friday, July 16, 2010 12:01:42 PM
Rank: Newbie

Joined: 7/16/2010
Posts: 3
Points: 9
Location: Sweden
Hi,

I've tried different ways of centering an image but without luck. For example, none of these snippets seem to center the image horizontally:

mySubItem.Content = @"<div align=""middle"" width=""300""><img index=""0""></img></div>";

mySubItem.Content = @"<div width=""300""><img align=""middle"" index=""0""></img></div>";

The image appears, but it's not centered. What am I doing wrong?

Is there anyway to horizontally center images without using ImageLists or file paths? I want my images to be on different sizes and only reside in memory. I'm happy to use the Image property on the items, as long as I know how to center it...

Thanks!
LidorSystems Support
Posted: Saturday, July 17, 2010 5:57:30 AM

Rank: Administration

Joined: 6/10/2005
Posts: 637
Points: 1,365
The <div> tag is only used as a starting block for entering XML created content. In the moment you cant specify the width of the block in this way, use a table instead:

Code:

private String assemblyFullPath = Application.ExecutablePath;

. . .

subItem.Content = "<div style=\"align:middlecenter\"><table width=\"100%\"><tr><td width=\"100%\"><img assemblypath=\"" + assemblyFullPath + "\" resource=\"Resources.search.ico\"></img></td></tr></table></div>";


As you can see from the code we also don't use image index. From v2.2 we have added an option to retrieve images embedded in other files: the same exe file of your application, resource dlls etc. In this case we are using the same application exe file to store images. In order to retrieve an image, you only need to set the assemblypath (the path of resource file) and the name of the resource.

There are also other ways to show images in subitems, for example by setting the ContentType of the specified column to Image. In this case all subitems for this column will show only images. For this case the Image or ImageIndex property for subitems is used. The alignment is set from ColumnFormatStyle.ContentAlign property.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Powered by Yet Another Forum.net version 1.9.0 (NET v2.0) - 10/10/2006
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.143 seconds.