How to Bold a Particular field in a list view
-
Hi I have a textbox in which user can enter some text and then i am populating a list view from database what ever matche with the user input in the textbox. I am getting the dataset and able to bind it to the list view. But i want to bold the particular field that exactly matches withe the input. is there any way to bold or highlight the particular field in a list view.. if any one knows the solution please help me.. Santhapur
-
-
Hi I am familiar with one that you hvae Given.. but i want to change the view (Bold ) of the particular cell.. not the entire row.. If you can please help me Santhapur
I was trying to solve this problem. In many ways I tried, but as per your requirement you have to add "TextBlock", then after that you can highlight the particular cell changing the Foreground colour. :laugh:
-
I was trying to solve this problem. In many ways I tried, but as per your requirement you have to add "TextBlock", then after that you can highlight the particular cell changing the Foreground colour. :laugh:
-
Now let us have a XAML file, where there is a listview where Employee data such as FirstName,LastName & EmployeeNumber is being populated. I assume you are retrieving data from you database when a specify condition is beieng satisfied such as when FirstName matches the condition. In this case you want to heighlight those cells. In this case your XAML file looks like: <ListView.View> :-D <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Employee Information"> <GridViewColumn Header="First Name" Width="100" > <GridViewColumn.CellTemplate> <DataTemplate> <l:EditBox Height="25" Value="{Binding Path=FirstName}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Last Name" Width="100" > <GridViewColumn.CellTemplate> <DataTemplate> <l:EditBox Height="25" Value="{Binding Path=LastName}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="ID" Width="50" > <GridViewColumn.CellTemplate> <DataTemplate> <l:EditBox Height="25" Value="{Binding Path=EmployeeNumber}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> Now in your cs class private void EditBox_Loaded(object sender, RoutedEventArgs e) { EditBox edtBox = sender as EditBox; if (edtBox.Value.ToString() == "Yajnesh") { edtBox.FontSize = edtBox.FontSize + 4; } } I have tried to paint the background, but it is not straight forward as you have to use the concept dependency property.
-
Now let us have a XAML file, where there is a listview where Employee data such as FirstName,LastName & EmployeeNumber is being populated. I assume you are retrieving data from you database when a specify condition is beieng satisfied such as when FirstName matches the condition. In this case you want to heighlight those cells. In this case your XAML file looks like: <ListView.View> :-D <GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Employee Information"> <GridViewColumn Header="First Name" Width="100" > <GridViewColumn.CellTemplate> <DataTemplate> <l:EditBox Height="25" Value="{Binding Path=FirstName}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Last Name" Width="100" > <GridViewColumn.CellTemplate> <DataTemplate> <l:EditBox Height="25" Value="{Binding Path=LastName}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="ID" Width="50" > <GridViewColumn.CellTemplate> <DataTemplate> <l:EditBox Height="25" Value="{Binding Path=EmployeeNumber}" Loaded="EditBox_Loaded"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> Now in your cs class private void EditBox_Loaded(object sender, RoutedEventArgs e) { EditBox edtBox = sender as EditBox; if (edtBox.Value.ToString() == "Yajnesh") { edtBox.FontSize = edtBox.FontSize + 4; } } I have tried to paint the background, but it is not straight forward as you have to use the concept dependency property.
Sorry this is not the complete solution. I will post an article having this functionality today. :laugh:
-
Sorry this is not the complete solution. I will post an article having this functionality today. :laugh:
-
I have posted ths article, please follow this link. http://www.code ;) project.com/KB/WPF/WPFHighlightCellListView1.aspx[^] Currently the code is not uploaded there as it is under scan, it will be available tomorrow.
-
I have posted ths article, please follow this link. http://www.code ;) project.com/KB/WPF/WPFHighlightCellListView1.aspx[^] Currently the code is not uploaded there as it is under scan, it will be available tomorrow.
-
Thanks for your article ... but i am binding it to a Ilist collection not to a table and i wont get the single result i will get a multiple result set. Aslesh
OK now your problem is mine as I am stuck at this point. I am also trying to bind a collection to this ListView at runtime & to highlight the search. End point is that in "EditBox_Loaded" method we can highlight it. You try how to bind the data collection at run time, as well as I am trying on my end.
-
Thanks for your article ... but i am binding it to a Ilist collection not to a table and i wont get the single result i will get a multiple result set. Aslesh
Hi Please go through the zip file of my article the solution for collection class is there. :-D
-
Hi Please go through the zip file of my article the solution for collection class is there. :-D