Ad
Showing Only Some Part Of The List On The Grid Control
Here is an exemplary code piece:
Model.cs
public class Datas
{
public int Region;
public int Frequency;
public int Amplitude;
}
MainViewModel.cs
public Datas Data1;
public MainViewModel()
{
DataList = new ObservableCollection<Datas>();
GetDatas();
}
public ObservableCollection<Datas> DataList { get; set; }
public void GetDatas()
{
...
...
var command = new SqlCommand($"Select [Region], [Frequency], [Amplitude].. WHERE REGION = '{SelectedRegion}..");
var dataReader = command.ExecuteReader();
while (dataReader.Read())
{
var Data1 = new Datas();
Data1.Region = dataReader["Region"];
Data1.Frequency = dataReader["Frequency"];
Data1.Amplitude = dataReader["Amplitude"];
DataList.Add(Data1);
}
connection.close();
}
(I tried to use DevExpressMVVM tools.)
MainView.xaml
<dxg:GridControl ItemsSource = "{Binding DataList} ...../>
Now; I can see the table on the window with Region, Frequency, and Amplitude columns and their values. But I want only to show the 2 columns; maybe like Frequency and Amplitude.
What would be the most efficient way to do this?
Ad
Answer
In XAML or in code you can set the column visibility to hidden. If you give a name to your datagrid you can access his properties.
<dxg:GridControl Name="myDatagrid" ItemsSource = "{Binding DataList} ...../>
then in code :
myDataGrid.Columns[0].Visibility = Visibility.Hidden;
Ad
source: stackoverflow.com
Related Questions
- → How to Fire Resize event after all images resize
- → JavaScript in MVC 5 not being read?
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → Getting right encoding from HTTPContext
- → How to create a site map using DNN and C#
- → I want integrate shopify into my mvc 4 c# application
- → Bootstrap Nav Collapse via Data Attributes Not Working
- → Shopify api updating variants returned error
- → Get last n quarters in JavaScript
- → ASP.NET C# SEO for each product on detail page on my ECOMMERCE site
- → SEO Meta Tags From Behind Code - C#
- → onchange display GridView record if exist from database using Javascript
- → How to implement search with two terms for a collection?
Ad