Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7445617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:53:03+00:00 2026-05-29T11:53:03+00:00

I am using ObjectListView in a C# winforms project and want to show a

  • 0

I am using ObjectListView in a C# winforms project and want to show a small icon in one of the columns.

So far, the icon is showing just fine, but it isn’t centered in the column, and I cannot find any documentation or code that pertains to image alignment within a column.

Here are the instructions for displaying an image as the column contents.

The code is virtually the same as the example given:

col_Important.AspectGetter = delegate(object x) { return ((ClassMyItem)x).IsImportant; };
col_Important.AspectToStringConverter = delegate(object x) { return String.Empty; };
col_Important.ImageGetter = delegate(object x)
    {
        return ((ClassMyItem)x).IsImportant? "star" : "none";
    };

Has anyone dealt with this issue and know of a way to center the image?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:53:05+00:00Added an answer on May 29, 2026 at 11:53 am

    In the process of manually drawing the subitem (using the DrawSubItem event), I inadvertently discovered that simply setting the ObjectListView property OwnerDraw to true actually centers the image.

    Just to be clear, here is how the columns with only an image are drawn:

    colName.AspectGetter = delegate(object x) { return ((MyClass)x).SomeProperty; };
    colName.AspectToStringConverter = delegate(object x) { return String.Empty }; };
    colName.ImageGetter =
        delegate(object x) { return ((MyClass)x).SomeProperty ? "icon" : "none"; };
    

    The ObjectListView has its SmallImageList set to use the ImageList I created for it, which is where the ImageGetter method makes use of the image name (“icon” in this example).

    By default, the images are drawn at the far left of the column, regardless of settings like text alignment, etc.

    By setting OwnerDraw to true for the ObjectListView, the images are miraculously centered in the column with no other code addition whatsoever. This was unexpected behavior which probably merits more investigation. For now it works, so maybe this tip will help someone else as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an TreeListView (a sub type of ObjectListView ) in my current project.
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
I am using ObjectListView to display a list of items. However columns are not
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Using JDeveloper , I started developing a set of web pages for a project
I'm using .NET 2.0 with standard controls. I want to display a simple list
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using WPF/PRISM I want to log my messages through ILoggerFacade to my GUI (A
Using jQuery, one can easily find out whether a particular element is visible using
I am currently using ObjectListView, and right now, i'm trying to get it so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.