创建新行后设置选择的ultragrid行

发布于 2024-12-04 04:21:29 字数 994 浏览 0 评论 0原文

我有一个包含很多行的超级网格,新行添加到末尾,我希望当添加新行时,选择该行并且网格也应该滚动到底部。

我本来打算尝试 ActiveRow 但它说它没有设置器

private void ultraButtonCreateNew_Click(object sender, EventArgs e)
        {
            DialogResult dr = new DialogResult();
            FormAddUnit form = new FormAddUnit();

            form.BuildingDataSet = _buildingDataSet;
            form.SectionDataSet = _sectionDataSet;
            form.UnitDataSet = _uc011_WizardStepUnitDataSet;
            form.SummaryDataSet = _summaryDataSet;
            form.FormState = WizardState.Create;
            form.Enablement = false;

            dr = form.ShowDialog();

            if (dr == DialogResult.Yes)
            {
                UC011_WizardStepUnitDataSet.UnitRow row = form.GetRow();
                _uc011_WizardStepUnitDataSet.Unit.AddUnitRow(row);
                SetUltraGridData();
                ultraGridOverview.DisplayLayout.ActiveRow = row;
                SetSummaryDataSet();
            }
        }

I have an ultragrid with lots of rows, new rows are added to the end, I want that when a new row is added, that row is selected and the grid also should scroll to the bottom.

I was going to try ActiveRow but it says it has no setter

private void ultraButtonCreateNew_Click(object sender, EventArgs e)
        {
            DialogResult dr = new DialogResult();
            FormAddUnit form = new FormAddUnit();

            form.BuildingDataSet = _buildingDataSet;
            form.SectionDataSet = _sectionDataSet;
            form.UnitDataSet = _uc011_WizardStepUnitDataSet;
            form.SummaryDataSet = _summaryDataSet;
            form.FormState = WizardState.Create;
            form.Enablement = false;

            dr = form.ShowDialog();

            if (dr == DialogResult.Yes)
            {
                UC011_WizardStepUnitDataSet.UnitRow row = form.GetRow();
                _uc011_WizardStepUnitDataSet.Unit.AddUnitRow(row);
                SetUltraGridData();
                ultraGridOverview.DisplayLayout.ActiveRow = row;
                SetSummaryDataSet();
            }
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔戏命师 2024-12-11 04:21:29

为了选择一行并将其滚动到视图中,您可以像这样调用一行上的激活方法

ultraGridOverview.Rows[ultraGridOverview.Rows.Count - 1].Activate() 

,或者您可以设置底层CurrencyManager的Position属性

CurrencyManager currencymanagerCustomers;
currencymanagerCustomers = this.BindingContext(ultraGridOverview.DataSource);
currencymanagerCustomers.Position = _uc011_WizardStepUnitDataSet.Rows.Count -1;

In order to select a row and scroll it into the view, you can either call the Activate Method on a row like this

ultraGridOverview.Rows[ultraGridOverview.Rows.Count - 1].Activate() 

or you can set the Position Property of the underlying CurrencyManager

CurrencyManager currencymanagerCustomers;
currencymanagerCustomers = this.BindingContext(ultraGridOverview.DataSource);
currencymanagerCustomers.Position = _uc011_WizardStepUnitDataSet.Rows.Count -1;
转身泪倾城 2024-12-11 04:21:29
private void ultraGrid1_BeforeRowDeactivate(object sender, CancelEventArgs e)
{
    if (!first) //Ignore this step if application has just started
    {
       UltraGrid g = (UltraGrid)(sender);
       r = g.ActiveRow;
       ultraGrid1.Rows[g.ActiveRow.Index].Cells["Is Closed"].Value = false; 
    }
}

这对我来说很有效,适用于多个乐队。

r 是一个全局变量,它存储对新创建的行的引用。
第一个是全局布尔值,在 Form_Load 结束时设为 false。

插入/创建行后,使用对 r 的引用来修改该行

private void ultraGrid1_BeforeRowDeactivate(object sender, CancelEventArgs e)
{
    if (!first) //Ignore this step if application has just started
    {
       UltraGrid g = (UltraGrid)(sender);
       r = g.ActiveRow;
       ultraGrid1.Rows[g.ActiveRow.Index].Cells["Is Closed"].Value = false; 
    }
}

This worked for me, over multiple bands.

r is a global var, which stores the reference to the newly created row.
first is a global bool which is made false at the end of Form_Load.

After the row is inserted/created use the reference to r to modify the row

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文