Gentlemen:
I have a WPF DataGrid that will be used to accept general journal postings from an operator.
I accept a general ledger account number in column zero and would like to display the account
title in column one following entry and acceptance of the account number. I am attempting
to do this in the CellEndEdit method. Nothing that I have tried seems to work. Any input
would be appreciated. Samples of my code follows. Ron.
XAML code:
<DataGrid x:Name="db_GL_Dist" GridLinesVisibility="All" VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Hidden" Height="225" Width="605"
AlternatingRowBackground="LightGray" AlternationCount="2"
CanUserResizeRows="false" CanUserResizeColumns="false"
HorizontalContentAlignment="Center" Margin="40,175,47,170" AutoGenerateColumns="False"
CellEditEnding="db_GL_Dist_CellEndEdit" BeginningEdit="db_GL_Dist_BeginningEdit" RowEditEnding="db_GL_Dist_RowEditEnding">
<DataGrid.Columns>
<DataGridTextColumn DisplayIndex="0" Header="Account No." Width="130"
IsReadOnly="False" Binding="{Binding accno}"/>
<DataGridTextColumn DisplayIndex="1" Header="Description" Width="190"
IsReadOnly="True" Binding="{Binding accdesc, NotifyOnSourceUpdated=True, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn DisplayIndex="2" Header=" Debit Amount" Width="130"
IsReadOnly="false" Binding="{Binding dramount, StringFormat={}{0:N2}}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn DisplayIndex="3" Header=" Credit Amount" Width="130"
IsReadOnly="false" Binding="{Binding cramount, StringFormat={}{0:N2}}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
C# code:
if (col == 0)
{
str3 = "select accdesc1, accstat from accmas where accno = \"" + content + "\";";
cmd3 = new MySqlCommand(str3, con3);
readin3 = cmd3.ExecuteReader();
readresult3 = readin3.Read();
if (!readresult3)
{
MessageBox.Show("Account number is not on file. Please re-enter.", "", MessageBoxButton.OK,
MessageBoxImage.Error);
OK_to_proceed = false;
}
else
{
glpdesc = readin3.GetString(0);
accstat = readin3.GetString(1);
if (accstat == "I")
{
MessageBox.Show("Account number is inactive. Please re-enter.", "", MessageBoxButton.OK,
MessageBoxImage.Error);
OK_to_proceed = false;
}
else
{
// instruction to load account title into column 1.
}
}
readin3.Close();
}