如何通过currencay经理将datagridview行的位置更改为新行(带星号的行)? [英] how change position of datagridview row to new row (row with star) by currencay manager?
本文介绍了如何通过currencay经理将datagridview行的位置更改为新行(带星号的行)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我用货币管理员来改变所选行的位置;效果很好;但是当我想要将行位置更改为新行时;它不起作用;只需要在第一行到最后一行之间进行更改;
如何解决?
Hi every body; I used currencymanager to change position of selected row; it works well; but when I want change the row position to the new row; it doesn't work; just can change between first row to last row;
how can solve it?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace GlassProducingManagement
{
public partial class Customers : Form
{
SqlDataAdapter sqlda1;
SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Hadi\documents\visual studio 2010\Projects\GlassProducingManagement\GlassProducingManagement\GMPdata.mdf;Integrated Security=True;User Instance=True");
DataTable dtCustomers;
CurrencyManager CM1;
public Customers()
{
InitializeComponent();
sqlda1 = new SqlDataAdapter("Select * From Customers", connection);
dtCustomers = new System.Data.DataTable();
sqlda1.Fill(dtCustomers);
dataGridView1.DataSource = dtCustomers;
CM1 = (CurrencyManager)(this.BindingContext[dtCustomers]);
private void btGotoNewRow_Click(object sender, EventArgs e)
{
CM1.Position = CM1.Count;
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1;
}
}
}
非常感谢您的帮助;
hadi
thank you very much for helping;
hadi
推荐答案
尝试下面
try below
private void btGotoNewRow_Click(object sender, EventArgs e)
{
CM1.AddNew();
CM1.Position = CM1.Count;
}
这篇关于如何通过currencay经理将datagridview行的位置更改为新行(带星号的行)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文