第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

C# WPF 以編程方式添加表格邊框

C# WPF 以編程方式添加表格邊框

C#
吃雞游戲 2023-07-22 16:43:11
我正在創(chuàng)建一個需要備份的程序。在儀表板上,我有一個以編程方式創(chuàng)建的表。不過我想要:表格邊框為#ccccccHeadcell 具有頂部邊框 #ffffff每行都有底部邊框 #cccccc我的程序截圖:繪制我想要的表格外觀:我的代碼(https://github.com/europa9/Windows_Backup_Folders_to_External_Disks_Csharp):
查看完整描述

1 回答

?
MM們

TA貢獻1886條經(jīng)驗 獲得超2個贊

您可以直接在元素上設置屬性Block:


var brushConverter = new BrushConverter();

var tableBorderBrush = brushConverter.ConvertFrom("#CCCCCC");

tableBorderBrush.Freeze();


var headerCellBorderBrush = brushConverter.ConvertFrom("#FFFFFF");

headerCellBorderBrush.Freeze();


private void drawLogTable() 

{

  Table oTable = new Table() { BorderThickness = new Thickness(1), BorderBrush = tableBorderBrush }


  // Add the header row with content,

  currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Date time"))) { BorderThickness = new Thickness(0, 1, 0, 0), BorderBrush = headerCellBorderBrush });

  currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Directory"))) { BorderThickness = new Thickness(0, 1, 0, 0), BorderBrush = headerCellBorderBrush });

  currentRow.Cells.Add(new TableCell(new Paragraph(new Run("File"))) { BorderThickness = new Thickness(0, 1, 0, 0), BorderBrush = headerCellBorderBrush });




  // Read file and add rows

  ...

  foreach (string line in existingFoldersArray)

  {

    ...


    // Add new row

    oTable.RowGroups[0].Rows.Add(new TableRow());

    currentRow = oTable.RowGroups[0].Rows[countLines];

    ...


    //Add the row's cells with their borders set

    currentRow.Cells.Add(new TableCell(new Paragraph(new Run(dateTime))) { BorderThickness = new Thickness(0, 0, 0, 1), BorderBrush = tableBorderBrush });

    currentRow.Cells.Add(new TableCell(new Paragraph(new Run(directory))) { BorderThickness = new Thickness(0, 0, 0, 1), BorderBrush = tableBorderBrush });

    currentRow.Cells.Add(new TableCell(new Paragraph(new Run(file))) { BorderThickness = new Thickness(0, 0, 0, 1), BorderBrush = tableBorderBrush });


    ...

  }

  ...

}

行的邊框是單元格的邊框。要設置行的邊框,TableCell必須設置每行的邊框。


我強烈建議使用 XAML 來DataTemplates完成此任務。這更容易、更易讀、更容易理解并且更靈活。您還可以使用 XAML 設計器的所見即所得功能。


查看完整回答
反對 回復 2023-07-22
  • 1 回答
  • 0 關(guān)注
  • 272 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號