【发布时间】:2021-09-20 14:58:50
【问题描述】:
使用 Xamarin 的 Syncfusion 数据网格表单如何获取单元格值的内容。我已经包含了 Syncfusion 提供的网格事件。
https://help.syncfusion.com/xamarin/datagrid/grid-events
<sfgrid:SfDataGrid x:Name="sfGrid"
AllowSorting="True"
ColumnSizer="Star"
AllowDraggingRow="True"
SelectedIndex="2"
AllowResizingColumn="True"
SelectionMode="Single"
AllowEditing="True"
NavigationMode="Cell"
AllowKeyboardNavigation="True"
AutoGenerateColumns="False"
ItemsSource="{Binding Students}">
<sfgrid:SfDataGrid.Columns x:TypeArguments="syncfusion:Columns">
<sfgrid:GridTextColumn HeaderText="First Name"
MappingName="FirstName" />
<sfgrid:GridTextColumn HeaderText="Last Name"
MappingName="LastName" />
<sfgrid:GridTextColumn HeaderText="TB"
MappingName="TB" />
<sfgrid:GridTextColumn HeaderText="PU"
MappingName="PU" />
</sfgrid:SfDataGrid.Columns>
</sfgrid:SfDataGrid>
例如,用户点击 TB 的单元格,在第 2 行该值为 108.7,我想获得该值。
public AcitivtyListPage()
{
InitializeComponent();
this.BindingContext = new StudentsViewModel();
sfGrid.CurrentCellActivated += SfGrid_CurrentCellActivated;
}
}
我尝试查看 CurrentCellActivated,但它似乎没有选定的单元格值对象。
private void SfGrid_CurrentCellActivated(object sender, Syncfusion.SfDataGrid.XForms.CurrentCellActivatedEventArgs e)
{
var item = sfGrid.GetSelectedCells();
}
我也尝试了这个示例,但它不适用于较新版本的控件,某些方法不再存在。
https://www.syncfusion.com/kb/7436/how-to-get-the-cell-value-of-specific-row-and-column
当红色框围绕网格单元格时,此图形应该解释它,我想要的值包含在该单元格中,请参见下图。
【问题讨论】:
-
CurrentCellActivatedEventArgs 有一个 CurrentRowColumnIndex 属性
-
是的,但我不想要那行数据我想要我在@Jason 上录制的单元格我只想更新它的值
-
CurrentRowColumn索引 - 这是特定单元格的索引,而不是整行
-
是的,但它返回给我的只是一个数字,而不是单元格ceotents数字我如何得到@Jason
标签: c# xamarin.forms syncfusion