我有一个带有SQL Server后端的c# .net应用程序。该应用程序根据条形码记录公司内的商品移动。用户将他们的项目与用户一起添加到软件中,每个用户都有一个分配的条形码。该软件伴随着一个位于墙上的物品跟踪系统。系统跟踪键例如,有一块板上有100个条形码的键,板上的每个位置都被编号为1-100。在软件中,用户需要能够看到“虚拟项目板”,它显示在虚拟板中布置的信息,显示哪个键在里面,哪个键出来了,谁有什么,等等,一目了然。
用户在第一次安装软件时将他们使用的容量系统编程到软件中,这样软件就知道他们使用的是100系统。我的问题是,如何动态创建表或某种形式的布局,以类似于网格的格式显示这些数据?我研究过使用tablelayoutpanel控件,但它似乎不能满足我的需要。我在Form_Load事件中有以下代码:
private void frmItemBoard_Load(object sender, EventArgs e)
{
try
{
// table data linked to form controls (first 5)
if (Properties.Settings.Default.systemsize == "5" || Properties.Settings.Default.systemsize == "5")
{
// load the layout for a 5 system
}
else if (Properties.Settings.Default.systemsize == "10")
{
// load the layout for a 10 system
}
else if (Properties.Settings.Default.systemsize == "25")
{
// load the layout for a 25 system
}
// etc.....
// other system sizes can go here. The software needs to support at least up to 20,000 keys somehow
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
发布于 2012-08-17 00:15:39
这样怎么样?
int size = Properties.Settings.Default.systemsize;
int height = 0;
int width = 0;
//check our sizes
if (size == 5)
{
height = 1;
width = 5;
else if (size == 10)
{
height = 2;
width = 5;
}
else if (size == 25)
{
height = 5;
width = 5;
}
//build a table
string table = "<table>";
for (int i = 1, i<=height,i++)
{
table += "<tr>"
for (int j = 1, j<=width,i++)
{
table += "<td>"
table += "some content"
table += "</td>"
}
table += "</tr>"
}
table += "</table>"
//write table to your page
https://stackoverflow.com/questions/11989619
复制相似问题