Created
February 16, 2016 18:46
-
-
Save hamxiaoz/948797e2324c7ee23c16 to your computer and use it in GitHub Desktop.
Ultra fast real-time data display in ObjectListView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Refresh the data in timer or in live data update callback | |
this.timer.Tick += (s, e) => { | |
// draw the live value | |
using (Graphics g = this.dataListView1.CreateGraphics()) | |
{ | |
// shrink the drawing area so that the grid line and selection color can be seen. | |
Rectangle r = lvi.GetSubItem(4).Bounds; | |
r.Inflate(-2, -2); | |
// use double buffer to avoid flicker | |
using (BufferedGraphics bg = BufferedGraphicsManager.Current.Allocate(g, r)) | |
{ | |
// clear the last graphics and draw | |
bg.Graphics.Clip = new Region(r); | |
bg.Graphics.Clear(this.dataListView1.BackColor); | |
((TextDecoration)(lvi.GetSubItem(4).Decoration)).Text = "Live Data"; | |
((TextDecoration)(lvi.GetSubItem(4).Decoration)).DrawText(bg.Graphics, r); | |
bg.Render(g); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment