我有一點問題。我有一個ListView,名爲lstPers,有4列。我想要做的是禁用編輯欄中的文字。所以我發現在計算器上列表視圖列錯誤
lstPers.Columns["Nume persoana"].ReadOnly = true;
此命令,但它給出了這樣的錯誤:
"System.Windows.Forms.ColumnHeader' does not contain a definition for 'ReadOnly' and no extension method 'ReadOnly' accepting a first argument of type 'System.Windows.Forms.ColumnHeader' could be found (are you missing a using directive or an assembly reference?)"
我一直在尋找的引用,但在沒有運氣。任何人都可以請幫我嗎?
你在哪裏運行這段代碼?在Form類中還是在不同的類中? – Steve
以勝利的形式。以下是創建ListView列的代碼。 (不是完整的代碼) //將子子項附加到ListView lstPers.Columns.Add(「Nume persoana」,200,HorizontalAlignment.Left); lstPers.Columns.Add(「CNP」,120,HorizontalAlignment.Left);lstPers.Columns.Add(「Data nasterii」,100,HorizontalAlignment.Left); lstPers.Columns.Add(「Profesia」,150,HorizontalAlignment.Left); lstPers.Columns.Add(「Adresa」,250,HorizontalAlignment.Left);「 –
創建列表視圖,效果很好,只需要一點點tweek就可以使其成爲只讀。 –