2010-08-08 17 views
7

के किसी सेल पर पॉप आउट के रूप में अतिरिक्त जानकारी जोड़ें, मेरे पास डेटाग्रिड में किसी सेल से बाहर निकलने वाली अतिरिक्त जानकारी कैसे हो सकती है?डेटाग्रिड

ग्रिड के एक कॉलम में, YES या NO मान है। NO मानों के लिए, मुझे एक स्पष्टीकरण देने की आवश्यकता है कि यह NO क्यों है। क्या कुछ सरल/स्पष्ट है जो यह कर सकता है?

उत्तर

0

क्या आपने सेल पर tooltip (सशर्त रूप से) बाध्य करने का प्रयास किया है?

ItemDataBound में टूलटिप डेटा सेट (या गतिशील <% बाध्यकारी #)

+0

क्या सेल दिखाएगा कि टूलटिप उपलब्ध है? – CJ7

+0

नहीं, यह नहीं होगा, हालांकि आप सेल पर एक CssClass जोड़कर भी ऐसा कर सकते हैं। यानी CssClass = "है-टूलटिप"। फिर अपनी रचनात्मकता का उपयोग करें और अधिक जानकारी के संकेत देने के लिए थोड़ा "i" आइकन जोड़ें। – Marko

+0

@ मार्को: क्या यह मूल रूप से एक स्मार्ट टैग नहीं है? – CJ7

1

तुम हमेशा एक StatusStrip स्थिति पट्टी से स्पष्टीकरण है और CellMouseEnter और CellMouseLeave घटनाओं सेट का उपयोग कर और (क्रमशः) निकाल सकते हैं।

private void dgvCellMouseEnter(object sender, DataGridViewCellEventArgs e) 
    { 
     statusStrip1.Text = (sender as DataGridView)[e.ColumnIndex, e.RowIndex].ToolTipText; 
    } 

    private void dgvCellMouseLeave(object sender, DataGridViewCellEventArgs e) 
    { 
     statusStrip1.Text = ""; 
    } 

एक अतिरिक्त सुविधा के रूप में, आप दिखा सकते हैं कि सेल में एक छोटा चिह्न दिखाकर "अतिरिक्त" जानकारी है जैसे एक्सेल करता है। यहाँ है कि मैं बिल्कुल वही चीज़ करते करने के लिए उपयोग कोड का एक छोटा स्निपेट है:

private void dgvCellPainting(object sender, DataGridViewCellPaintingEventArgs e) 
    { 
     if (e.ColumnIndex != -1) && (e.RowIndex != -1) 
     { 
      DataGridViewCell dgvCell = (sender as DataGridView)[e.ColumnIndex, e.RowIndex]; 

      Pen greenPen = new Pen(Color.Green, 2); 
      Boolean hasTooltip = !dgvCell.ToolTipText.Equals(""); 
      Boolean hasCompleted = (dgvCell.Tag as CellInfo).complete; // CellInfo is a custom class 

      if (hasTooltip) && (hasCompleted) 
      { 
       e.Handled = true; 
       e.Paint(e.ClipBounds, e.PaintParts); 
       e.Graphics.DrawRectangle(Pens.Blue, e.CellBounds.Left + 5, e.CellBounds.Top + 2, e.CellBounds.Width - 12, e.CellBounds.Height - 6); 
       e.Graphics.DrawRectangle(greenPen, e.CellBounds.Left + 1, e.CellBounds.Top + 1, e.CellBounds.Width - 3, e.CellBounds.Height - 3); 
      } 
      else if (hasTooltip) 
      { 
       e.Handled = true; 
       e.Paint(e.ClipBounds, e.PaintParts); 
       e.Graphics.DrawRectangle(Pens.Blue, e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width - 2, e.CellBounds.Height - 2); 
      } 
      else if (hasCompleted) 
      { 
       e.Handled = true; 
       e.Paint(e.ClipBounds, e.PaintParts); 
       e.Graphics.DrawRectangle(greenPen, e.CellBounds.Left + 1, e.CellBounds.Top + 1, e.CellBounds.Width - 3, e.CellBounds.Height - 3); 
      } 
     } 
    } 

इस कोड को सेल यदि hasTooltip सच है, एक हरे रंग की सीमा है अगर hasCompleted सच है, और दोनों सीमाओं के चारों ओर एक नीले बॉर्डर के ड्रॉ (साथ अंदर हरा एक) यदि दोनों सच हैं।

+0

स्टेटस स्ट्रिप कहां प्रदर्शित होता है? – CJ7

+0

आप इसे कहां रखना चाहते हैं, हालांकि, स्टेटस स्ट्रिप्स आम तौर पर फॉर्म के नीचे डॉक किए जाते हैं। – Jesse

-1

क्या आपने ASP.NET AJAX PopupControl को आजमाया है? आप किसी भी नियंत्रण पर पॉप अप कर सकते हैं और पॉपअप पैनल जैसे पैनलों के अंदर नियंत्रण रखने जितना आसान है।

0

पंक्ति विवरण का उपयोग करने का प्रयास करें; आप पंक्ति के बारे में विस्तृत जानकारी प्रदर्शित करने के लिए RowDetailsTemplate निर्दिष्ट कर सकते हैं। आप पंक्ति विवरण here का एक उदाहरण देख सकते हैं।