vb.net2003 中如何控制datagrid中cell不全选

zhxinbo 2007-05-31 10:03:35
比如 在datagrid中选中一个单元格 然后按 上 下 左 右 方向键 光标移动。每次移动到下一个单元格 都是全选的。。
现在我想要实现不要全选,直接定位在单元格的开始位置。。(单元格有的是多行的)
...全文
125 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
scow 2007-06-01
  • 打赏
  • 举报
回复
画除第一列之外的所有列,背景色画成白色。
public class DataGridColoredTextBoxColumn : DataGridTextBoxColumn
{
protected override void Paint(System.Drawing.Graphics g,
System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager
source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush
foreBrush, bool alignToRight)
{
try
{
backBrush = new LinearGradientBrush(bounds,
Color.White,
Color.White,
LinearGradientMode.BackwardDiagonal);
foreBrush = new SolidBrush(Color.Black);

}
catch (Exception) { /* empty catch */ }
finally
{
//judge whether the row is current selected, and paint to diffent color
//according to it,for whether selected is in higher priority
if (!this.DataGridTableStyle.DataGrid.IsSelected(rowNum))
// make sure the base class gets called to do the drawing with
// the possibly changed brushes
base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);

}
}
}
让其他列都继承DataGridColoredTextBoxColumn ,未测试,请调试一下
zhxinbo 2007-06-01
  • 打赏
  • 举报
回复
没 人知道吗。。。
rainbowsoftware 2007-05-31
  • 打赏
  • 举报
回复
学习中·
zhxinbo 2007-05-31
  • 打赏
  • 举报
回复
再顶
zhxinbo 2007-05-31
  • 打赏
  • 举报
回复
我自己顶一把

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧