我正在c#.net 2010中开发一个Windows应用程序。它基本上是一个库存管理应用程序。用户将在此处制作发票。
问题在于发票中的商品数量可能是n
个。如何从n
个项目中获取用户的输入?
在VB6.0中,我使用带有文本框的mshflex网格,并根据需要将不同的控件集成到mshflexgrid中。
答案 0 :(得分:0)
您可以使用可编辑的DataGridView
。用户可以直接将详细信息键入GridView行,而不是填写Invoice Forms。这将允许用户插入任意数量的发票详细信息。
修改强>
打开当前聚焦的单元格旁边的窗口。
您可以使用CellEnter
事件,当Cell
将焦点放在DatGridView上时会被触发。
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
{
//Give the relevant column index where pop up windows needs to be opened.
if (e.ColumnIndex.Equals(1))
{
//Getting the position of the current cell.
Point loc = dataGridView1.PointToScreen(dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location);
}
}
答案 1 :(得分:0)
您可以使用GridView。您可以按如下方式在每个单元格中输入数据:
dataGridView1.Rows[rowIndex].Cells[columnIndex].Value = value;
只需输入以下代码即可插入新行:
this.dataGridView1.Rows.Add();
还有另一种方法。您可以使用文本框,组合框,标签,按钮等创建用于存储单个项目信息的表单。输入项目的数据后,使用按钮可以保存数据。然后清除所有控件。现在,输入下一个项目的信息,依此类推。