I'm importing GridView
from excel
I need to show a message near every empty cell to give the user information about what it should be writing..
void simpleButton1_Click(object sender, System.EventArgs e)
{
string[] msg = new string[60];
string[] error = new string[400];
for (int i = 0; i < gridView3.RowCount ; i++)
{
System.Data.DataRow Rows = gridView3.GetDataRow(i);
string cellvalue = Rows[0].ToString();
if (cellvalue == "")
{
msg[0] = "Missing 'First Name'";
error[i] = msg[0] + " - ";
}
cellvalue = Rows[1].ToString();
if (cellvalue == "")
{
msg[1] = "Missing 'Last Name'";
error[i] += msg[1] + " - ";
}
//...
}
}
How can I put the variable msg[]
to the specific cell with a little image or "!"
figure or maybe I can color the cell
Maybe you can use a
ToolTip
to show your alert:You only need to guess the location of the cell based on the sizes of the rows and columns of the
DataGridView
.ToolTip
is inSystem.Windows.Forms
namespace.You can color the XtraGrid cells using Conditional Formatting feature:
Result:
Related Links:
Customizing Appearances of Individual Rows and Cells
Style Format Conditions
Custom Painting (Samples)
Reference: How to: Provide Custom Display Text for Data Cells
check the example empty strings are displayed within the "Discount" column's cells if they contain zero values.
If you want to show
Image and text
both then you need to handle the GridView.CustomDrawCell event of your GridView, here is a snip of code that change the color of the Name column, based on an other column valoe (age column)To change the color of cell