Skip to content

ListView.IndexOfKey() returns incorrect value #2867

Closed

Description

This issue has been moved from a ticket on Developer Community.


Bom dia á todos, o que ocorre é o seguinte, quando inserimos um controle ListView em um Form VB, acontece que eu declaro em Design as colunas deste ListView e sempre coloco na propriedade (Name) das colunas um nome realtivo á esta coluna, até aí tudo bem em Design!

Mas o problema suge no momento em Execução, sendo que em execução todas as propriedades (Name) das colunas se torna uma string vazia, então o que acontece acredito seja um problema no VB, pois em Design o mesmo mantém os campos das colunas da ListView (Name) só que em execução perdemos estes campos!

Então fiz o teste de adicionar na programação todos os campos das colunas (Name) e os mesmos colocando na programação se mantém em todo o processo da execução, então vejo que o problema é manter o mesmo que foi feito em Design também em execução!

Espero que tenham compreendido a minha explicação e que isso realmente seja um porblema que possa ser corrigido em uma atualização futura!

Grato,
Renato


Original Comments

Visual Studio Feedback System on 1/17/2020, 07:42 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Zheng Li [MSFT] on 1/19/2020, 10:15 AM:

Dear customer, thanks for your feedback.

I can’t repoduce the issue accordind to ypur description, Please see the reproduce gif, and figure out if there have wrong steps. And could you please provide more info for us to investigate the issue in the future, such as your reproduce Video, or reproduce gif.

In addtion, have you have the same experience in before, such VS 16.2, VS 2017. And if the issue also can reproduce on C# Windows Form Application.

Repro Gif:

Thanks

Zheng

Renato Maia on 1/23/2020, 00:52 AM:

See that the program is running without change and with its column names declared in the control, but as soon as it is executed, it no longer has this information! So I put the name of the columns in code and it doesn't lose in execution!

Renato Maia on 1/21/2020, 07:16 PM:

Good morning my friend, thanks for the feedback you gave and the work you had in making a GIF of the procedure, well what I can say you did correctly what is happening, but the problem is generated when the application is running , because when running these Listview columns (Name) are completely reset (string.empty), that is, you don't have any more information about them running, so you must insert them again in code, so the system keeps these columns (Name) in Listview! So I can use the columns .IndexOfKey, because I believe that you remember more (name) than Interger to return it!

* I using Google Translate for creat this text!

Zheng Li [MSFT] on 1/22/2020, 11:00 AM:

Dear customer, thankk for your response.

For the issue, could you please provide more details for use? such as your repro reproduce steps/Gif/Video etc.

There have some confused that about the “The issue generated when application is runing”,what’s meaning? it’s that calling the columns(Name) in running? how to implement it?

Will be appreciate if you also can provide your project for us to investigate the issuein future?

Thanks
Zheng

Zheng Li [MSFT] on 2/5/2020, 04:25 PM:

Thanks for your response, Ciould you please provide reproduce steps & project for us tp investigate the issue in tthe future.

Thanks
Zheng

Visual Studio Feedback System on 2/12/2020, 08:17 PM:

We will close this report in 14 days because we don’t have enough information to investigate further. To keep the problem open, please provide the requested details.

Renato Maia on 2/13/2020, 00:53 AM:

Hi friend, i send details of problem to user Zheng Li, no have more details with me! I send the video of project and see the problem!

Zheng Li [MSFT] on 2/17/2020, 02:29 PM:

Dear customer, thanks for your help and details info.

For the issue, we found the root cause is that Docs say that ColumnHeaderCollection.IndexOfKey uses ColumnHeader.Name property as the key. However designer does not generate ‘columnHeader1.Name =”columnHeader1”; line in InitializeComponent in designer.cs. As a result, runtime does not have this value and uses an empty string as a key in the columns collection.

And we provide the workaround for now, please refer it, and we are investigate it for now, will give you a response once have ny process.

Workaround
So when I do this:
public Form1()
{
InitializeComponent();
columnHeader1.Name = “columnHeader1”;
columnHeader2.Name = “columnHeader2”;
}

    private void button1_Click(object sender, EventArgs e)
    {
        Text = "IndexofKey " + listView1.Columns.IndexOfKey("columnHeader1");
    }

This code works as expected and returns 0.

Thanks
Zheng


Original Solutions

(no solutions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

🪲 bugProduct bug (most likely)area-VSDesignerWindows Forms out-of-proc designer related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions