Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 工具提示问题跳过Datagrid中的行_C#_Datagrid_Datatable_Tooltip_C# 2.0 - Fatal编程技术网

C# 工具提示问题跳过Datagrid中的行

C# 工具提示问题跳过Datagrid中的行,c#,datagrid,datatable,tooltip,c#-2.0,C#,Datagrid,Datatable,Tooltip,C# 2.0,到目前为止,这是我的代码,不幸的是它没有提供准确的结果。。由于某些原因,即使显示正确的索引,它也会随机混淆ID的顺序 ***使用datagrid,而不是datagridview ***Visualstudio2005环境中的visual C#2.0 编辑: 我不能复制它。这对我很有用: private void dataGridSignal_MouseMove(object sender, MouseEventArgs e) { this.toolTip.Hide(dataGridSigna

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

***使用datagrid,而不是datagridview

***Visualstudio2005环境中的visual 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());
}

我只能猜测DataGrid使用的数据源与来自
GetSignalTable
的数据源不同。在我的示例中,
dt
是我的DataGrid dg正在使用的数据表。

您不能只使用
datagridSignal
而不是dt和dv吗?除了prop变量之外,它们似乎都是不必要的。是的,这会清理代码,但我想我会使用这些变量,只是为了让问题尽可能清楚。这无助于解决我的问题。对了,这没什么区别sadly@DarthSheldon更新答案。我只能猜测您的
GetSignalTable
与网格实际使用的不同。可能不是,因为其他几个函数使用我的gettable函数,而且它们似乎只是fine@DarthSheldon与其使用
GetSignalTable
,不如尝试强制转换它:
DataTable dt=(DataTable)dataGridSignal.DataSource好,所以你是一个聪明的人。通过使用DataView dv=(DataView)dataGridSignal.DataSource;现在它像陀螺一样工作。荣誉
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();
  }
}