Line separation / Line break in a listbox

梦想的初衷 提交于 2019-12-25 02:44:21

问题


I want to display 2 sets of data on the one list box, for example, I would wont to display the 7 times table and the 8 times table on the same listbox. Here is how I get the first set of data displaying:

            int awnser = 0;
        int z;
        z = int.Parse(textBox1.Text);

        for (int i = 0; i < 11; i++)
        {
            awnser = z * i;

            listBox6.Items.Add(z + " * " + i + " = " + awnser.ToString());
        } 

But how do I get a line break or separation so I can put the 8 times table just underneath?


回答1:


How about this?

EDIT Insert it AFTER your loop

        listBox6.Items.Add(z + " * " + i + " = " + awnser.ToString());
    } 

listBox6.Items.Add("--------------------");



回答2:


In WPF this is easy to do using a custom template, but in WinForms I think you must do it by rendering the list items yourself.

Look at this example where they override the OnDrawItem method: http://www.syncfusion.com/FAQ/windowsforms/faq_c87c.aspx#q627q



来源:https://stackoverflow.com/questions/3667817/line-separation-line-break-in-a-listbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!