| 发表于:2007-04-04 10:16:193楼 得分:0 |
private void datagridview1_cellformatting(object sender, datagridviewcellformattingeventargs e) { if (datagridview1.columns[e.columnindex].name.equals( "列名 ")) { // ensure that the value is a string. string stringvalue = e.value as string; if (stringvalue == null) return; // set the cell tooltip to the text value. datagridviewcell cell = datagridview1[e.columnindex, e.rowindex]; cell.tooltiptext = stringvalue; // replace the string value with the image value. switch (stringvalue.trim()) { case "v1 ": e.cellstyle.backcolor = color.yellow; cell.selected = true; break; } } } | | |
|