An object-oriented programming language developed by Microsoft that can be used in .NET.
if you are using window forms, then you should be using DataGridView, if WPF then DataGrid. In neither is cell.IsValid supported. vb6 is no longer supported.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have written a small VB app that Illustrates the issue; I've uploaded the essential files; it should be obvious how to extract the individual files from that concatenation and rebuild the app.
The application just creates a DataGrid then populates it with a single row DataTable. As shown by clicking the button, no matter how one clicks in the DataGrid, CurrentCell.IsValid is ALWAYS False. How can this be fixed?
An object-oriented programming language developed by Microsoft that can be used in .NET.
if you are using window forms, then you should be using DataGridView, if WPF then DataGrid. In neither is cell.IsValid supported. vb6 is no longer supported.
Hi @RogerSchlueter-7899 ,
Thank you for the clarification.
You're correct that DataGridCellInfo.IsValid is a supported property in WPF. As documented in Microsoft Learn, the DataGrid.CurrentCell property returns a DataGridCellInfo structure, which provides the IsValid property.
According to the documentation, IsValid returns False when either of the following conditions is met:
Since you've mentioned that CurrentCell.IsValid consistently returns False even after clicking different cells, it would be helpful to determine which of these conditions is occurring.
Could you please check the values of DataGrid.CurrentCell.Item and DataGrid.CurrentCell.Column after clicking a cell?
You can use the following VB.NET code to inspect the current cell information:
Dim cellInfo = MyDataGrid.CurrentCell
Debug.WriteLine(
$"CurrentCell.IsValid: {cellInfo.IsValid}"
)
Debug.WriteLine(
$"Item is UnsetValue: {Object.ReferenceEquals(cellInfo.Item, DependencyProperty.UnsetValue)}"
)
Debug.WriteLine(
$"Column is Nothing: {cellInfo.Column Is Nothing}"
)
Please replace MyDataGrid with the name of your DataGrid control. This check would help determine whether the current cell is considered invalid because its item or column information is missing. However, it would not necessarily establish why that information is not being updated when a cell is clicked.
Additionally, could you please confirm which .NET Framework or .NET version your WPF application is targeting (for example, .NET Framework 4.8 or .NET 10)?
I appreciate the time you've taken to prepare and share a sample application. The results of these checks, along with the target framework version, would help narrow down the behavior you're experiencing.
If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.
Thank you.