我也是web转win
哎~~~~~~~~~~~~~~~
困惑

解决方案 »

  1.   


    在form1中 的 datagrid中添加这个行就可以比较容易
      

  2.   

    来一贴先获得DATAGRID行里的唯一字段,也就是你数据记录的唯一字段,下面的方法是得到值,你可以看看
    private void dataGridView_CurrentCellChanged(object sender, System.EventArgs e)
    {
    SqlConnection con = new SqlConnection(ConStr);
    this.txtId.Text = dataGridView[Convert.ToInt32(dataGridView.CurrentCell.RowNumber),0].ToString();
    this.dataGridView.Select(dataGridView.CurrentCell.RowNumber); string query_sql = "select * from accounttype where id = '" + txtId.Text + "'";
    SqlDataAdapter da = new SqlDataAdapter(query_sql,con);
    DataSet ds = new DataSet();
    da.Fill(ds,"accounttype");
    this.txtTempid.DataBindings.Clear();
    this.txtTempid.DataBindings.Add("Text",ds,"AccountType.Id");
    }
    下面是把获得的唯一字段传给你的From2这时候要注意了,怎么才能把值传过去
    private void btnUpdate_Click(object sender, System.EventArgs e)
    {
    if(txtId.Text != "")
    {
    //用你Form2的构造函数接收这个值,然后在根据这个值把字段全部绑定到控件上,后来你就可以做更新或者别的什么了,呵呵
    FrmUpdate frmupdate = new FrmUpdate(txtId.Text);
    this.Close();
    str_id = this.txtId.Text;
    frmupdate.ShowDialog();
    }
    else
    {
    MessageBox.Show("请选择记录进行修改!","提示",MessageBoxButtons.OK,MessageBoxIcon.Question);
    }
    }
      

  3.   

    就是,我以为不会太难。
    先重新查询数据库,填充到当前DATAGRID中,然后查询要定位的行就可以啦
      

  4.   

    try
    http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp
      

  5.   


    这个比较复杂了
    如果保存原来的行道是简单,用个变量 保存原来的 位置即可

    //一下以这种榜定方式为例
    dataGrid1.DataSource =ds.Tables[0]; 
    //取得当前绑定上下文的位置
    int psoindex = [Form1].BindingContext[ds.Tables[0]].Position
    //弹出 Form2 更新数据略.............
    //Form2 返回后
    [Form1].ds.Tables[0].Clear()
    [Form1].da.Fill(ds)
    [Form1].BindingContext[ds.Tables[0]].Position = psoindex
    /*
    建议 方一个 DataView 在窗口上那样 还能取得用户的 排序信息
    dv.table= [Form1].ds.Tables[0]
    dataGrid1.DataSource = dvint psoindex = [Form1].BindingContext[dv].Position*/不过如果 多用户时 原来选的那行被 其他用户删除了
    如和 处理就要你自己考虑了