[quote=引用 8 楼 一个武小猴子的回复:]这个公布到前端的数据 只需要套取一个前端框架就可以了。看你用什么前端框架了,这个效果很简单的,很多框架都已经封装好的。
我想做一个连接SQL Server的一个表,将表里面的信息公布到大屏幕上,数据上下滚动显示,给大家看的,求助高手指导该用什么控件呢?datagridview吗?还是listview?大概方案是什么,本人是初学者,还请大师指导方案,谢谢!
这个公布到前端的数据 只需要套取一个前端框架就可以了。看你用什么前端框架了,这个效果很简单的,很多框架都已经封装好的。
簡單做了一個 DataTable dtTmpSource = new DataTable(); DataTable dtSource = new DataTable(); private void Form3_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("1"); for (int i = 0; i <20; i++) { dt.Rows.Add(i.ToString()); } dtTmpSource = dt; dtSource = dt; this.dataGridView1.DataSource = dt; } private void timer1_Tick(object sender, EventArgs e) { //label1.Left = label1.Left + 10; //if (label1.Right > this.Width) // label1.Left = 0; int index = this.dataGridView1.FirstDisplayedScrollingRowIndex; this.dataGridView1.Rows[index].Selected = true; // 设置为选中. this.dataGridView1.FirstDisplayedScrollingRowIndex++; //如果数据太少.就不滚动 if (index == this.dataGridView1.FirstDisplayedScrollingRowIndex) { return; } //将刚才定位的数据插入到dtSource的末尾.这是为了实现循环滚动. dtSource.ImportRow(dtSource.Rows[index]); //rowCount为记录总数 if (this.dataGridView1.FirstDisplayedScrollingRowIndex > dataGridView1.RowCount - 1) { //初始时,将数据取出同时放在dtSource 与dtTmpSource中, //现在dtSource中,已增加了很多数据. //因而在所有原数据都遍历完,开始下一次遍历时,将原数据覆盖现在的dtSource ; dtSource = dtTmpSource; this.dataGridView1.FirstDisplayedScrollingRowIndex = 0; } // this.dataGridView1.FirstDisplayedScrollingRowIndex = this.dataGridView1.Rows.Count - 1; }
js实现滚动 https://blog.csdn.net/waterDjj/article/details/52022081
[quote=引用 3 楼 C#初学者1 的回复:] [quote=引用 1 楼 ManBOyyy的回复:]就textbox或者lable就行了吧 滾動的 private void timer1_Tick(object sender, EventArgs e) { label1.Left = label1.Left + 10; if (label1.Right > this.Width) label1.Left = 0; label2.Top = label2.Top + 10; if (this.label2.Bottom > this.Height) label2.Top = 0; }
[quote=引用 1 楼 ManBOyyy的回复:]就textbox或者lable就行了吧 滾動的 private void timer1_Tick(object sender, EventArgs e) { label1.Left = label1.Left + 10; if (label1.Right > this.Width) label1.Left = 0; label2.Top = label2.Top + 10; if (this.label2.Bottom > this.Height) label2.Top = 0; }
就textbox或者lable就行了吧 滾動的 private void timer1_Tick(object sender, EventArgs e) { label1.Left = label1.Left + 10; if (label1.Right > this.Width) label1.Left = 0; label2.Top = label2.Top + 10; if (this.label2.Bottom > this.Height) label2.Top = 0; }
110,534
社区成员
642,575
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧