Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / December 2006

Tip: Looking for answers? Try searching our database.

Culture prevents listview columns autosizing?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 22 Dec 2006 12:24 GMT
I have discovered a problem in the Compact Framework that can only be
reproduced by running the same code against an English and German
emulator/device.

I am setting ColumnHeader.Width to -1 and -2, to find the best fit for each
column. Setting the width to -1/-2 does autosize the column on my English
devices/emulator, but fails completely when run against a German emulator
(the width is only set to 0). Example of the code:

foreach (ColumnHeader ch in listView.Columns)
{
    // get width by column header text
    ch.Width = -2;
    int w = ch.Width;

    // now get longest item width
    ch.Width = -1;

    // is this less than the column header width?
    if (ch.Width < w)
    {
        // yes - then use the column header width
        ch.Width = w;
    }
}

More example code at end of post...

There is seemingly no rhyme or reason for this, and I cannot say I expect to
get much more than confirmation back from you guys that this is an issue, but
that at least would make me feel sane!!

Working around this issue is also proving most difficult, as I am having
difficulty creating the graphics object for the listView control.

Merry Christmas!

Rob

--

More example test case code:

public Form1()
{
    this.mainMenu1 = new System.Windows.Forms.MainMenu();
    this.listView1 = new System.Windows.Forms.ListView();

    this.listView1.Location = new System.Drawing.Point(8, 8);
    this.listView1.Size = new System.Drawing.Size(224, 184);
    this.listView1.HeaderStyle = ColumnHeaderStyle.Nonclickable;
    this.listView1.View = View.Details;

    this.Controls.Add(this.listView1);
    this.Menu = this.mainMenu1;
    this.Text = "Form1";

    this.Load += new System.EventHandler(this.Form1_Load);
}

private void Form1_Load(object sender, System.EventArgs e)
{
    for (int i = 0; i < 3; i++)
    {
        ColumnHeader ch = new ColumnHeader();
        ch.Text = "Column" + i;
        listView1.Columns.Add(ch);
    }

    foreach (ColumnHeader ch in listView.Columns)
    {
        // get width by column header text
        ch.Width = -2;
        int w = ch.Width;

        // now get longest item width
        ch.Width = -1;

        // is this less than the column header width?
        if (ch.Width < w)
        {
            // yes - then use the column header width
            ch.Width = w;
        }
    }
}
Linda Liu [MSFT] - 25 Dec 2006 11:42 GMT
Hi Rob,

Thank you for posting here!

I noticed that the problem you discovered is in the Compact Framework. I am
sorry to tell you that the Compact Framework related issues are not in our
support range.

Please post your issue in the
microsoft.public.dotnet.framework.compactframework newsgroup to seek for
assistance.

Thank you for your understanding and Merry Christmas!

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jeff Gaines - 25 Dec 2006 11:52 GMT
On 25/12/2006 in message <B$31KnBKHHA.2304@TK2MSFTNGHUB02.phx.gbl> Linda
Liu [MSFT] wrote:

[snipped]

>Sincerely,
>Linda Liu
>Microsoft Online Community Support

It's Christmas day, what are you and the MSFT team doing working!!!

Happy Christmas to you and the whole MSFT team and many thanks for all
your help and support :-)

Signature

Jeff Gaines

Robert - 28 Dec 2006 12:32 GMT
Linda,

This newsgroup does not appear as a MSDN managed newsgroup.

> Please post your issue in the
> microsoft.public.dotnet.framework.compactframework newsgroup to seek for assistance.
Linda Liu [MSFT] - 29 Dec 2006 09:42 GMT
Hi Rob,

Thank you for your feedback.

Yes, the microsoft.public.dotnet.framework.compactframework newsgroup is
not a managed newsgroup.

FYI, you could make a suggestion to MSDN Managed Newsgroups at the
following link.

https://support.microsoft.com/common/survey.aspx?scid=sw%3Ben%3B1296&showpag
e=1&ws=msdn&sd=msdn&pa=msdnw

For more links about MSDN Managed Newsgroup, you may visit our team's blog:

http://blogs.msdn.com/msdnts/

Under the 'MSDN Managed Newsgroup Links' part  at the lower-left corner of
our team's blog, you'll see several links.

Good luck to you!

Sincerely,
Linda Liu
Microsoft Online Community Support

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.