我想做一個連接SQL Server的一個表,將表里面的資訊公布到大螢屏上,資料上下滾動顯示,給大家看的,求助高手指導該用什么控制元件呢?datagridview嗎?還是listview?大概方案是什么,本人是初學者,還請大師指導方案,謝謝!
uj5u.com熱心網友回復:
就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;
}
uj5u.com熱心網友回復:
投屏的用H5+js就好,那個只講顯示效果,不管業務邏輯。當然你用H5+js就成。這種東西,都不用管資料庫不資料庫的,讓前端先把UI實作都行
uj5u.com熱心網友回復:
這兩個控制元件能顯示表格資料嗎?表格里好多資料,4-5列,上百行啊?
uj5u.com熱心網友回復:
那還是用datagridview把
uj5u.com熱心網友回復:
就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;
}
這兩個控制元件能顯示表格資料嗎?表格里好多資料,4-5列,上百行啊?
那還是用datagridview把
大師,能告訴下我,怎么能讓資料上下滾動顯示資訊呢?
uj5u.com熱心網友回復:
簡單做了一個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;
}
uj5u.com熱心網友回復:
js實作滾動https://blog.csdn.net/waterDjj/article/details/52022081
uj5u.com熱心網友回復:
這個公布到前端的資料 只需要套取一個前端框架就可以了。看你用什么前端框架了,這個效果很簡單的,很多框架都已經封裝好的。
uj5u.com熱心網友回復:
js實作滾動
https://blog.csdn.net/waterDjj/article/details/52022081
感謝你,可惜我還不會,初學者,只會#
uj5u.com熱心網友回復:
簡單做了一個
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;
}
感謝大師分享,拿回來研究下??
uj5u.com熱心網友回復:
這個公布到前端的資料 只需要套取一個前端框架就可以了。看你用什么前端框架了,這個效果很簡單的,很多框架都已經封裝好的。
c#初學者,還有很多不懂的
uj5u.com熱心網友回復:
不錯,注記一下,以后可用uj5u.com熱心網友回復:
這個公布到前端的資料 只需要套取一個前端框架就可以了。看你用什么前端框架了,這個效果很簡單的,很多框架都已經封裝好的。
c#初學者,還有很多不懂的
是不是winfrom的
uj5u.com熱心網友回復:
datagirdview,進行資料展示就行。該容器功能強大。uj5u.com熱心網友回復:
或者用listview控制元件uj5u.com熱心網友回復:
listboxlistboxlistboxlistboxlistboxlistboxlistboxuj5u.com熱心網友回復:
我想做一個連接SQL Server的一個表,將表里面的資訊公布到大螢屏上,資料上下滾動顯示,給大家看的,求助高手指導該用什么控制元件呢?datagridview嗎?還是listview?大概方案是什么,本人是初學者,還請大師指導方案,謝謝!
DataGridView將所指定的資料庫的內容添加到DataGridView的.text
uj5u.com熱心網友回復:
這種問題還是要看用什么技術吧 是web還是Winform 或者是WPFweb h5+js
winform 好像是listview(沒怎么用過winform )
WPF listview就OK
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/155222.html
標籤:C#
上一篇:C#制作卡拉OK點歌系統
下一篇:c#自定義事件一直報錯,求指教
