2013-01-17 11 views
7

में विशिष्ट पंक्ति में ग्रिड लाइनों को छिपाना मैं एक खाली पंक्ति प्राप्त करना चाहता हूं। इसलिए मैं एक विशिष्ट पंक्ति में ग्रिड लाइनों को छिपाना चाहता हूं। मैं यह कैसे कर सकता हूँ?DataGridView

Grid.CellBorderStyle = DataGridViewCellBorderStyle.None; 

नहीं है, लेकिन इस ग्रिड के लिए लागू किया जा सकता है।

उत्तर

1

untested है, लेकिन आप CellPainting घटना से निपटने और यह एकदम सही नहीं है, लेकिन मुझे आशा है कि आप कुछ विचार प्राप्त कर सकते DataGridViewParts.Border

e.Paint(e.ClipBounds, DataGridViewPaintParts.All^DataGridViewPaintParts.Border); 
    e.Handled = true; 
0

बहिष्कृत करके आपको क्या चाहिए पाने के लिए सक्षम होना चाहिए।

DataGridView

this.dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None; 
this.dataGridView1.AllowUserToResizeRows = false; 
this.dataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; 


private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) 
{ 
    if (e.RowIndex == -1) return; 
    // Calculate the bounds of the row. 
    Rectangle rowBounds = new Rectangle(
     this.dataGridView1.RowHeadersWidth, e.RowBounds.Top, 
     this.dataGridView1.Columns.GetColumnsWidth(
      DataGridViewElementStates.Visible) - 
     this.dataGridView1.HorizontalScrollingOffset + 1, 
     e.RowBounds.Height); 

    // Paint the custom background. 
    using (Brush backbrush = 
     new SolidBrush(this.dataGridView1.GridColor), backColorBrush = new SolidBrush(Color.White)) 
    { 
     using (Pen gridLinePen = new Pen(backbrush)) 
     { 
      //Apply to spicific row 
      if (e.RowIndex == 2) 
      { 
       e.Graphics.FillRectangle(backbrush, rowBounds); 

       // Draw the inset highlight box. 
       e.Graphics.DrawRectangle(Pens.Blue, rowBounds); 
      } 
     } 
    } 
} 

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) 
{ 
    if (e.RowIndex == -1) return; 
    if (e.Value != null) 
    { 
     // Draw the text content of the cell, ignoring alignment of e.RowIndex != 2 
     if (e.RowIndex != 2) 
     { 
      e.Graphics.DrawString((String)e.Value, e.CellStyle.Font, 
      Brushes.Black, e.CellBounds.X + 2, 
      e.CellBounds.Y + 2, StringFormat.GenericDefault); 
     } 
    } 
    e.Handled = true; 
} 

संदर्भ के डिजाइन:
DataGridView.RowPrePaint Event
DataGridView.CellPainting Event