Nasıl yapılır: Program Aracılığıyla Seçili Hücreler İçeren Çalışma Sayfalarındaki Satırlarda Biçimlendirmeyi Değiştirme
Metnin kalın olması için seçilmiş hücreyi içeren satırın tümünün yazı tipini değiştirebilirsiniz.
Uygulama alanı: Bu konudaki bilgiler Excel 2013 ve Excel 2010 uygulamalarının belge düzeyi projelerine ve uygulama düzeyi projelerine yöneliktir. Daha fazla bilgi için bkz. Office Uygulamalarında Kullanılabilir Özellikler ve Proje Türü.
Geçerli satırı kalın yapma ve önceden kalın olan satırı normal yapma
Önceden seçilmiş olan satırın kaydını tutmak için statik değişken bildirin.
Static previousRow As Integer = 0
static int previousRow = 0;
ActiveCell özelliğini kullanarak geçerli hücreye başvuru alın.
Dim currentCell As Excel.Range = Me.Application.ActiveCell
Excel.Range currentCell = this.Application.ActiveCell;
Etkin hücrenin EntireRow özelliğini kullanarak geçerli hücreyi kalın yapın.
currentCell.EntireRow.Font.Bold = True
currentCell.EntireRow.Font.Bold = true;
previousRow'un geçerli değerinin 0 olmadığına emin olun.0 (sıfır), bu kodun üzerinden ilk kez geçildiğini belirtir.
If previousRow <> 0 Then
if (previousRow != 0)
Geçerli satırın önceki satırdan farklı olduğuna emin olun.
If currentCell.Row <> previousRow Then
if (currentCell.Row != previousRow)
Önceden seçilmiş olan satırı temsil eden aralığa başvuru alın ve o satırı kalın olmayacak biçimde ayarlayın.
Dim rng As Excel.Range = DirectCast(ws.Rows(previousRow), Excel.Range) rng.EntireRow.Font.Bold = False
Excel.Range rng = (Excel.Range)ws.Rows[previousRow]; rng.EntireRow.Font.Bold = false;
Geçerli satırın bir sonraki geçişte önceki satıra dönüşebilmesi için, onu depolayın.
previousRow = currentCell.Row
previousRow = currentCell.Row;
Aşağıdaki örnekte tamamlanmış bir yöntem gösterilmektedir.
Örnek
Private Sub BoldCurrentRow(ByVal ws As Excel.Worksheet)
' Keep track of the previously bolded row.
Static previousRow As Integer = 0
' Work with the current active cell.
Dim currentCell As Excel.Range = Me.Application.ActiveCell
' Bold the current row.
currentCell.EntireRow.Font.Bold = True
' If a pass has been done previously, make the old row not bold.
' Make sure previousRow is not 0 (otherwise this is your first pass through).
If previousRow <> 0 Then
' Make sure the current row is not the same as the previous row.
If currentCell.Row <> previousRow Then
Dim rng As Excel.Range = DirectCast(ws.Rows(previousRow), Excel.Range)
rng.EntireRow.Font.Bold = False
End If
End If
' Store the new row number for the next pass.
previousRow = currentCell.Row
End Sub
// Keep track of the previously bolded row.
static int previousRow = 0;
private void BoldCurrentRow(Excel.Worksheet ws)
{
// Work with the current active cell.
Excel.Range currentCell = this.Application.ActiveCell;
// Bold the current row.
currentCell.EntireRow.Font.Bold = true;
// If a pass has been done previously, make the old row not bold.
// Make sure previousRow is not 0 (otherwise this is your first pass through).
if (previousRow != 0)
// Make sure the current row is not the same as the previous row.
if (currentCell.Row != previousRow)
{
Excel.Range rng = (Excel.Range)ws.Rows[previousRow];
rng.EntireRow.Font.Bold = false;
}
// Store the new row number for the next pass.
previousRow = currentCell.Row;
}
Ayrıca bkz.
Görevler
Nasıl yapılır: Program Aracılığıyla Çalışma Kitaplarındaki Aralıklara Biçimler Uygulama
Nasıl yapılır: Çalışma Sayfaları Arasında Program Aracılığıyla Veri ve Biçimlendirme Kopyalama