English 中文(简体)
工具提示发行在 Datagrid 中跳过行
原标题:ToolTip issue skipping Rows in Datagrid
private void datagridSignal_MouseMove(object sender, MouseEventArgs e) 
{         this.toolTip.Hide(datagridSignal);         
this.toolTip.RemoveAll();         
DataTable dt = GetSignalTable();         
DataView dv = new DataView(dt);         
Point prop = new Point(e.X, e.Y);         
System.Windows.Forms.DataGrid.HitTestInfo myHitTest;                 
myHitTest = datagridSignal.HitTest(prop.X, prop.Y);         
this.toolTip.SetToolTip(datagridSignal, " ID =  " + (int)dv[myHitTest.Row][0] + "    " + myHitTest.Row + " "); 
} 

这是到目前为止的代码, 不幸的是它没有提供准确的结果。 因为某种原因, 它会随机混淆IDs的顺序, 即使正确的索引正在显示 。

*** 使用数据格网, 而非数据格网视图

*** 在2005年的视觉研究环境中,可视C#2.0

编辑:

private void dataGridSignal_MouseMove(object sender, MouseEventArgs e)
{
  this.toolTip.Hide(dataGridSignal); 
  this.toolTip.RemoveAll(); 
  System.Windows.Forms.DataGrid.HitTestInfo myHitTest;  
  myHitTest = dataGridSignal.HitTest(e.X, e.Y);
  this.toolTip.SetToolTip(dataGridSignal, " ID = " + ((int)this.GetTable().Rows[myHitTest.Row][0]).ToString() + " "+ myHitTest.Row.ToString());
}
最佳回答

我不能复制它,这对我有用:

void dg_MouseMove(object sender, MouseEventArgs e) {
  this.toolTip1.Hide(dg);
  this.toolTip1.RemoveAll();

  System.Windows.Forms.DataGrid.HitTestInfo myHitTest = dg.HitTest(e.X, e.Y);

  if (myHitTest.Row > -1) {
    this.toolTip1.SetToolTip(dg, "Over " + dt.Rows[myHitTest.Row][0].ToString());
    this.Text = "Over " + dt.Rows[myHitTest.Row][0].ToString();
  }
}

我只能猜测数据Grid所使用的数据源与来自 GetSignal Table 的数据源不同。 在我的例子中, dt 就是我的数据Grid dg正在使用的数据表。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签