Dynamic hint depending on the mouse over a row in a datagrid (NOT a datagridview)

I am trying to make sure that when the user translates the rows in my DataGrid / dataview, each row will display a different prompt result.

I can’t figure it out. with a DataGrid, how can I say mouseOver in each row and provide row specific data? it looks like all of my regular sources on the internet aren’t causing anything!

no, if there is a way to do this work with datagridview, I don’t know how to fill it (datagridview), since my table changes in length every time the program starts. (the program monitors the signals, therefore, if more signals are received, the table has more rows ...)

* note: this is visual C # 2.0 in 2005 visual studio.

* ended as follows:

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(eX, eY); System.Windows.Forms.DataGrid.HitTestInfo myHitTest; prop = datagridSignal.PointToClient(prop); myHitTest = datagridSignal.HitTest(prop.X, prop.Y); this.toolTip.SetToolTip(datagridSignal, " ID = '" + (int)dv[myHitTest.Row][0] + "' "); } 
+6
source share
2 answers

Why don't you handle the MouseMove event in the grid? Then you can convert the mouse coordinates to a line handle and change the grid tooltip accordingly.

Sort of:

 private void dataGrid_MouseMove(object sender, MouseEventArgs e) { var point = dataGrid.PointToClient(eX, eY); var hittest = dataGrid.HitTest(point.X, point.Y); toolTip1.SetToolTip(dataGrid, hittest.Row); // add Tooltip conotrol to the form!!! } 
+1
source

You can do this in XAML:

 <extToolkit:DataGrid Name="dgData" AutoGenerateColumns="False"> <extToolkit:DataGrid.RowStyle> <Style TargetType="{x:Type extToolkit:DataGridRow}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=DataContext.ID}" /> </Trigger> </Style.Triggers> </Style> </extToolkit:DataGrid.RowStyle> <extToolkit:DataGrid.Columns> <extToolkit:DataGridTextColumn Header="ID" Binding="{Binding ID}" /> <extToolkit:DataGridTextColumn Header="First Data" Binding="{Binding FirstData}" /> <extToolkit:DataGridTextColumn Header="Second Data" Binding="{Binding SecondData}" /> </extToolkit:DataGrid.Columns> </extToolkit:DataGrid> 
+2
source

Source: https://habr.com/ru/post/916387/


All Articles