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

  • Home
  • SEARCH
  • 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 8712387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:05:57+00:00 2026-06-13T05:05:57+00:00

I am attempting to re-size only certain columns of a ListView based on the

  • 0

I am attempting to re-size only certain columns of a ListView based on the remaining size after any static width column widths are calculated. For example, I do not want columns, such as quantity, price, etc… to resize but, I would like columns that typically have wider data such as name, description to get wider. Here is the method that I am attempting to use below but, it is not working.

BTW, I am calling this method when the ClientSizeChanged Event fires on the ListView. Not sure if that is relevant or not.

    public static void ResizeListViewColumns(ListView lv, List<int> fixedColumnIndexes, List<int> nonFixedColumnIndexes)
    {
        int lvFixedWidth = 0;
        int lvNonFixedWidth = 0;
        if (fixedColumnIndexes.Count + nonFixedColumnIndexes.Count != lv.Columns.Count)
        {
            throw new Exception("Number of columns to resize does not equal number of columns in ListView");
        }
        else
        {
            // Calculate the fixed column width
            // Calculate the non-fixed column width
            // Calculate the new width of non-fixed columns by dividing the non-fixed column width by number of non-fixed columns
            foreach (var fixedColumn in fixedColumnIndexes)
            {
                lvFixedWidth += lv.Columns[fixedColumn].Width;
            }

            foreach (var nonFixedColumn in nonFixedColumnIndexes)
            {
                lvNonFixedWidth += lv.Columns[nonFixedColumn].Width;
            }

            int numNonFixedColumns = nonFixedColumnIndexes.Count;
            foreach (var newNonFixedColumn in nonFixedColumnIndexes)
            {
                lv.Columns[newNonFixedColumn].Width = lvNonFixedWidth / numNonFixedColumns;
            }
        }
    }
  • 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-06-13T05:05:58+00:00Added an answer on June 13, 2026 at 5:05 am

    Something like this should for you… Instead of keeping a list of fixed and unfixed indices, in my example I set the “Tag” property of each fixed column to the string “fixed”.

    int fixedWidth = 0;
            int countDynamic = 0;
    
            for (int i = 0; i < listView1.Columns.Count; i++)
            {
                ColumnHeader header = listView1.Columns[i];
    
                if (header.Tag != null && header.Tag.ToString() == "fixed")
                    fixedWidth += header.Width;
                else
                    countDynamic++;
            }
    
            for (int i = 0; i < listView1.Columns.Count; i++)
            {
                ColumnHeader header = listView1.Columns[i];
    
                if (header.Tag == null)
                    header.Width = ((listView1.Width - fixedWidth) / countDynamic);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to use sizeWithFont as follows: [commentTextLabel.text sizeWithFont:commentTextLabel.font constrainedToSize:CGSizeMake(commentTextLabel.frame.size.width, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap]; When I
I have a problem when attempting to size a component in a class a
Is there a size limit to saving dictionaries? I am attempting to write a
I'm attempting to use the following to get the height & width of the
I'm attempting to write an algorithm that takes an array of size n and
I am attempting to build out a visual jQuery based browser for thumbnailed assets
I'm attempting to react to a size change in my app. Or more specifically
I am attempting to fix the size of a widget in GTK+, specifically using
I'm attempting to determine the end of an English sentence (only approximately), by looking
I am attempting to programmatically monitor the size of a SQL Server database, 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.