2016-11-08 17 views
0

我正在創建一個應用程序,允許用戶使用DataGridView控件輸入/編輯儀器詳細信息。按下保存(從菜單條),我想將DataGridView表中的任何數據傳輸到Windows註冊表 - 這可能嗎?是否有將DataGridView數據傳輸到Windows註冊表的方法?

我似乎只能通過按鈕找到有關添加到註冊表的信息。我創建了一個簡單的註冊表的應用程序,它可以讓您通過使用下面的代碼在窗體上按鈕從註冊表中添加和刪除:

Microsoft.Win32.RegistryKey key; 


    private void button1_Click(object sender, EventArgs e) 
    { 
     key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Sanaa"); 
     key.SetValue("Leonardo_edi", "Sanaa"); 
     key.Close(); 
    } 

我有更大的應用程序的一個較小的原型版本,直到我能得到這個部分的工作,其中可以看到下面:

I'd like each entry in the table to be a folder name within the Registry, with the different parameters such as "Age", "School" to be entries in this folder.

+0

您應該能夠從DataGridView獲取值,但是允許用戶將數據直接輸入到註冊表中聽起來像是一場等待發生的災難。你確定這是你想要的嗎? – JohnG

+0

@JohnG這是大學項目的要求之一。 – Sanaa

+0

好的......然後,MavisBeacon建議循環通過DataGridView中的行,如:「foreach(dataGridView.Rows中的DataGridViewRow行)'然後'string cell1 = row.Cells [0] .Value.ToString();'.. – JohnG

回答

0

檢查這個答案here

基本上你使用你必須更新1個註冊表值邏輯,但它適用於每一行在數據網格中循環遍歷行。

相關問題