tbmvp

Hi, i got confused with the property "text" of a listviewitem.
When i add a listviewitem to the listview control with the "text" property such as the "10:00 PM wake up" string, the item in the listview control only display the front part "10:00 PM", and which instead of the string"wake up" is a ellipsis in runtime.
Then, the next time i start the application the item display all the text "10:00 PM wake up".
I don't know why

I really want to display all the text in the listviewitem by using the "Add" method of the listview control, but i can't figure it out myself.

How can i do it

Thanks in advance.



Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

Guang-Ming Bian - MSFT

Hi tbmvp,

I have tried a sample like you mentioned, I find if the column width is not enough, it will use ellipsis instead. So you can change the column width wider to try.

I tried the code, and it works fine.

Code Block

private void button1_Click(object sender, EventArgs e)
{
ListViewItem lst = new ListViewItem();
lst.SubItems.Add("10:00 PM wake up");
lst.SubItems.Add("10:00 PM wake up");
listView1.Items.Add(lst);

}

Best regards,

Guang-Ming Bian - MSFT






Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

tbmvp

Hi, Guang-Ming Bian.
Sorry for what i did not metioned yet is I did not use the column property in the listview, i just want to list the items without the column, so i set the this property "listView.View = System.Windows.Forms.View.List".

In this case, there is always display the ellipsis instead.

Plus, i stored all the listview items in a xml file. And the next time i start my application again, the listview item which i stored before in the listview display all the text just like"10:00 Wake up", there is no ellipsis, so weird, i do not know why

Could you please tell me how i can deal with it in this case





Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

Guang-Ming Bian - MSFT

Hi tbmvp,

I have tried a sample about list view, it still works fine.

Code Block

private void button1_Click(object sender, EventArgs e)

{

listView1.View = View.List;

ListViewItem lst = new ListViewItem();

lst.Text = "10:00 PM wake up";

listView1.Items.Add(lst);

}

it won't appear ellipsis. I suggest you make the listview control wider.

If you still can't solve your problem, could you please show your code about it

Thanks,

Guang-Ming Bian - MSFT






Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

tbmvp

Hi,thanks for your reply.
And it is too complex to show all my code, so i pick up some important code block below.
There are two forms in my application,one is the main form "mainForm", the other is "anotherForm". When i click the button "anotherForm" which in the main form the "anotherForm" will show up. Then if the DialogResult returns "DialogResult.OK" the "anotherForm" will return a string value "ListviewAddValue" back to the "mainForm" and add the string as a listviewitem.
Here is the code in the main form:

private void anotherForm_Click(object sender, EventArgs e)
{
anotherForm.ShowDialog();

if (anotherForm.DialogResult != DialogResult.Cancel)
{
ListViewItem lvi = new ListViewItem(anotherForm.ListviewAddValue);

listView1.Items.Add(lvi);
}
}

And here is the code in the "anotherForm":

public string ListviewAddValue
{
get
{
return cboxRecurrence.SelectedItem.ToString().Substring(0, 1) +
" " + dtpClockTime.Value.ToLongTimeString() + " " + txtNote.Text;
}
}

The string value for the ListviewAddValue property returns back could be "D 10:00 PM wake up " in my demo.





Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

Guang-Ming Bian - MSFT

Hi tbmvp,

I read your code, it just like my code, I would suggest you create a new project and write a simple example to test , just use my code . If it succeed, maybe something wrong in other code.

Best regards,

Guang-Ming Bian - MSFT






Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

tbmvp

OK, I will check my code.
Thanks again.




Re: Smart Devices VB and C# Projects how can i display all the text in a listviewitem?

Rajat Solanky (MCSE, MCSD)

Hi tbmvp,
I am not trying it but I think that if you increase the width of listViewItem, than you can see all on screen.
bay
try it. good luck
Rajat.