创建新行后设置选择的ultragrid行
我有一个包含很多行的超级网格,新行添加到末尾,我希望当添加新行时,选择该行并且网格也应该滚动到底部。
我本来打算尝试 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了选择一行并将其滚动到视图中,您可以像这样调用一行上的激活方法
,或者您可以设置底层CurrencyManager的Position属性
In order to select a row and scroll it into the view, you can either call the Activate Method on a row like this
or you can set the Position Property of the underlying CurrencyManager
这对我来说很有效,适用于多个乐队。
r 是一个全局变量,它存储对新创建的行的引用。
第一个是全局布尔值,在 Form_Load 结束时设为 false。
插入/创建行后,使用对 r 的引用来修改该行
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