110,545
社区成员
发帖
与我相关
我的任务
分享
private void toolStripButton_Click(object sender, EventArgs e)
{
int iCount = this.dataGridView1.Rows.Count;
if (iCount != 0)
{
for (int i = 0; i < iCount; i++)
{
b[i] = true;//哪些行的姓名需要在第二个窗体显示的标记,通过窗体传递
this.dataGridView1[0, i].Value = true;
}
this.pictureBox1.Refresh();
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))//列表为空时不响应
{
DataGridViewColumn column = this.dataGridView1.Columns[e.ColumnIndex];
int currentRowIndex = this.dataGridView1.CurrentRow.Index;//选中的当前行
//所有CheckBox列
if (column is DataGridViewCheckBoxColumn)
{
if (e.RowIndex == currentRowIndex && e.ColumnIndex == 0)//选中行、第0列
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[currentRowIndex].Cells["Column1"];
Boolean flag = Convert.ToBoolean(checkCell.Value);
if (flag == true) //CheckBox被选中
{
//勾选事件
}
else
{
//未勾选事件
}
}
}
}
}
int iNameColumnNum=2;//姓名在第几列
int iCount = this.dataGridView1.Rows.Count;
string[] sName=new string[1000];
if (iCount != 0)
{
for (int i = 0; i < iCount; i++)
{
sName[i]=this.dataGridView1[iNameColumnNum, i].Value;
}
}
//姓名列所有数据
public string[] sName=new string[1000];
public string[] SName
{
get { return SName; }
set { SName = value; }
}
//打开第二个窗体
Form2 form2 = new Form2();
form2.Owner = this;
form2.Show();
//第二个窗体Form1_Load事件中
string[] sName2=new string[1000];
Form1 fForm = (Form1)this.Owner;
sName2 = fForm.SName;
ImportStockInfo isi = new ImportStockInfo();
isi.bw = bw;
isi.dwea = e;