[英]How do I get rid of the MissingManifestResourceException in WPF?
[英]How do I get rid of the empty table in my gridview WPF?
因此,我最近在WPF中為數據庫應用程序創建了GridView。 它保存了我的網站用戶的用戶名和密碼,並且運行良好。唯一的問題是,它在右側添加了空列,但我沒有理由。 我做錯了什么以及如何正確做? 我無法單擊右邊的列,就像它只是null。
XML格式
<DataGrid HeadersVisibility="Column" CanUserAddRows="False" BorderBrush="Black" Name="dgAccounts" Foreground="Black" Margin="10,103,405,10">
<DataGrid.Columns>
</DataGrid.Columns>
</DataGrid>
C#
private void RetrieveUserData()
{
string line;
using (WebClient wc = new WebClient())
{
string accs = wc.DownloadString(Clipboard.GetText());
using (StringReader sr = new StringReader(accs))
{
while ((line = sr.ReadLine()) != null)
{
newAccounts.Add(new Accounts { Username = theUsername, Password = thePassword });
}
}
}
dgAccounts.ItemsSource = newAccounts;
}
假設您的DataGrid
為固定大小,則空列將作為其他列的結果,僅使用它們所需的空間。
嘗試設置每列的寬度,我建議使用Width="*"
來確保使用整個網格,並且每列使用相等的空間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.