Aracılığıyla paylaş


Nasıl Yapılır: Seçili Hücreler İçeren Çalışma Sayfalarındaki Satırlar İçindeki 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 2007 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

  1. Ö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;
    
  2. 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;
    
  3. 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; 
    
  4. 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)
    
  5. Geçerli satırın önceki satırdan farklı olduğuna emin olun.

    If currentCell.Row <> previousRow Then
    
    if (currentCell.Row != previousRow)
    
  6. Ö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, missing];
    rng.EntireRow.Font.Bold = false;
    
  7. 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, missing];
            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: Çalışma Kitaplarındaki Aralıklara Biçimler Uygula

Nasıl Yapılır: Verileri ve çalışma sayfası üzerinde biçimlendirmeyi kopyalama

Kavramlar

Çalışma Sayfaları ile Çalışma

Office Çözümlerinde İsteğe Bağlı Parametreler