2011-12-02 30 views
2

我正在研究我的程序,我儘管將輸出更改爲更友好的數據顯示。目前我正在使用一個文本框,它只是打印出所有信息。我想改變它,因爲我希望每個記錄旁邊的刪除按鈕不能與文本框一起使用。創建更友好的用戶界面。我的想法是可能的嗎?

我正在考慮用某種行的顯示,這種行可以通過主窗口拉伸。每行都會顯示我的顯示器應顯示的所有內容,但條目ID。每行必須能夠消失並出現,取決於條目是否被刪除或添加。

你有想法嗎?

有沒有一種方法來顯示每一行數據像顯示的數據?我可以使用VS中的哪個工具來執行此操作?

這是我現在該怎麼顯示的數據:

enter image description here

+1

我想你想一個DataGridView – Danny

+2

這個問題可能屬於上[UX(http://ux.stackexchange.com /)。 – LarsTech

+0

@Danny:我不認爲datagridview會是個好主意。我的輸出看起來像MS Access行和列,我正在使用它來存儲我的實際數據,如果它看起來像MS Access本身lol,那麼我的程序的目的就會消失。 – HelpNeeder

回答

2

你的「入口」的項目看基於圖像像他們具有不同的屬性。條目ID#2有四個項目,而其他項目有三個。基於此,您可以使用ListBoxDrawMode = OwnerDrawVariable

簡單列表框例如:

private List<int> entries = new List<int>(); 

public Form1() { 
    InitializeComponent(); 

    entries.Add(3); 
    entries.Add(4); 
    entries.Add(3); 

    listBox1.DrawMode = DrawMode.OwnerDrawVariable; 
    listBox1.MeasureItem += new MeasureItemEventHandler(listBox1_MeasureItem); 
    listBox1.DrawItem += new DrawItemEventHandler(listBox1_DrawItem); 
} 

private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e) { 
    if (e.Index > -1) 
    e.ItemHeight = (((int)listBox1.Items[e.Index]) * 16) + 8;  
} 

private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { 
    e.DrawBackground(); 

    if (e.Index > -1) { 
    ControlPaint.DrawBorder3D(e.Graphics, e.Bounds); 
    for (int i = 0; i < (int)listBox1.Items[e.Index]; i++) { 
     TextRenderer.DrawText(e.Graphics, 
          "Item #" + i.ToString(), 
          e.Font, 
          new Point(e.Bounds.Left + 4, (e.Bounds.Top + 4) + (i * 16)), 
          Color.Black); 
    } 
    } 
} 

結果:

enter image description here

+0

這看起來並不壞,我不知道我可以在列表框中做到這一點。 – HelpNeeder

相關問題