I'm using a data grid control from Syncfusion in my .NET MAUI application, and now I want to update a singe cell that the user clicked on. In the XAML code I have this:
<syncfusion:SfDataGrid x:Name="PasswdVw" ItemsSource="{Binding PassWrd}"
SelectedRow="{Binding SelPassRws, Mode=TwoWay}" SelectionMode ="Multiple"
NavigationMode="Row"
HeaderRowHeight="35" CellLongPress="PasswdVw_CellLongPress">
<syncfusion:SfDataGrid.Columns>
<syncfusion:DataGridTextColumn MappingName="PassId" Visible="False"/>
<syncfusion:DataGridTemplateColumn MappingName="PassTitle" HeaderText="Title"
CellPadding="3" HeaderTextAlignment="Center" ColumnWidthMode="FitByCell">
<syncfusion:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<local:HyperlinkLabel Text="{Binding PassTitle}"
BackgroundColor="White"
Url="{Binding PassUrl}"/>
</DataTemplate>
</syncfusion:DataGridTemplateColumn.CellTemplate>
</syncfusion:DataGridTemplateColumn>
<syncfusion:DataGridTextColumn MappingName="PassUsrname" HeaderText="User Name"
HeaderTextAlignment="Center" ColumnWidthMode="FitByCell"/>
<syncfusion:DataGridTextColumn MappingName="PassPassword" HeaderText="Password"
HeaderTextAlignment="Center" Width="150"/>
<syncfusion:DataGridTextColumn MappingName="PassUrl" Visible="False"/>
<syncfusion:DataGridTextColumn MappingName="PassGrpName" HeaderText="Group"
HeaderTextAlignment="Center" ColumnWidthMode="FitByCell"/>
<syncfusion:DataGridTextColumn MappingName="PassNotes" HeaderText="Notes"
Width="100" HeaderTextAlignment="Center"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
My behind code for the CellLongPress event is:
private void PasswdVw_CellLongPress(object sender, DataGridCellLongPressEventArgs e)
{
if(e.RowColumnIndex.ColumnIndex == 3)
{
var passData = e.RowData as PasswrdInfo;
string tmpPass, newPass;
using(SqlConnection c = new SqlConnection(App.ConnStr))
{
string query = "select password from PassWrds where Id = " + passData.PassId;
using(SqlCommand cmd = c.CreateCommand())
{
c.Open();
tmpPass = cmd.ExecuteScalar().ToString();
c.Close();
}
}
newPass = Crypto.Decrypt(App.secretKey, tmpPass);
}
}
So now I'm at a point where I want to set the cell that was clicked to the newPass
.
I tried PasswdVw[e.RowColumnIndex.RowIndex].Cell[3]
and other things similar as well as playing around with e.RowColumnIndex.RowIndex
and e.RowColumnIndex.ColumnIndex
but I just keep getting errors.
How can I set the cell that was clicked to the variable named newPass
?