I recently started this new project in XAML / C# using Visual Studio, now for some reason when I try to take user's input by using a Visual Basic InputBox so I can then use the thing the user typed as the name of the column it excecutes the functions but it does not display the newly created column. The worst thing is that there are no errors showing up in the IntelliSense error detector that Visual Studio offers.
Here is the part of the code that I used to Add and Remove the column (C#):
private void AddColumnButton_Click(object sender, RoutedEventArgs e)
{
// Prompt the user for the column name
string columnName = Microsoft.VisualBasic.Interaction.InputBox("Enter the name of the new column:", "Add Column");
// Add the new column to the DataTable
DataColumn newColumn = new DataColumn(columnName);
table.Columns.Add(newColumn);
// Set the DataTable's ItemsSource property to the new DataView
DataView view = table.DefaultView;
DataTable.ItemsSource = view;
}
private void RemoveColumnButton_Click(object sender, RoutedEventArgs e)
{
if (table.Columns.Count != 3)
{
if (table.Columns.Count > 0)
{
table.Columns.RemoveAt(0);
DataTable.ItemsSource = table.DefaultView;
}
}
}
And here is the entire code:
I tried to change it to an approach where you type the name of the column in the same window, but it does not display it either.