FrameworkElement focusedElement = Keyboard.FocusedElement as FrameworkElement; if (focusedElement != null) { string focusedControlName = focusedElement.Name; if (focusedControlName == "txtPolicyNumber") { iefInsuranceThirdPartyVM.CanAutoDrop = true; txtPolicyNumber.Focus(); // WTF is making it focus on the combobox } }
We have a issue with WPF RadComboBox to disable the auto selection of first item while databinding.
I have large set of data (say 10000 items) in the application cache.
<telerik:RadComboBox
x:Name="itemBox"
HorizontalAlignment="Stretch"
telerik:TextSearch.TextPath="Name"
CanAutocompleteSelectItems="False"
DisplayMemberPath="Name"
EmptyText="Select item"
IsEditable="True"
IsFilteringEnabled="True"
IsReadOnly="False"
IsTextSearchEnabled="True"
ItemsSource="{Binding ItemCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
OpenDropDownOnFocus="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
TextSearchMode="Contains">
<telerik:EventBinding
Command="{Binding BeginSearchCommand}"
EventName="KeyUp"
PassEventArgsToCommand="True" />
</telerik:RadComboBox>
We have the RadCombobox with Filter enabled.
BeginSearchCommand relay command method has implementation of filtering the cached ItemCollection and setting the value.
this.ItemCollection = new QueryableCollectionView(new ObservableCollection<ItemModel>(filtereditems));
I first load 50 items in RadCombobox and the user will try to search the items from SearchText . Then the items in the cache is filtered with searchtext and the result is assigned with the datasource property.
The couple of action above continues. Please help us disable autoselect while databinding.
Hi,
I have a problem, that I cannot solve. I have a Grid View (see attachment) based on a SQL Table. Now have replaced some colums with a comboBox.
The comboBoxes receive the data from the following table.
| ID | Country | Plant | Area | Machine |
------------------------------------------------
| 1 | DE | MUC | BA | A |
| 2 | DE | MUC | BA | A |
| 3 | AT | VIE | BE | 1 |
| 4 | AT | VIE | BE | 2 |
F.e. The column "Country" in my GridView has as ItemSource a grouping of the column Country. Now I want to update the comboBox "Plant" depending on the value of the ComboBox "Country" meaning that when "DE" is chosen, it should only show "MUC" as a possible entry. How can I do that? Here is my code.
Thanks.
public partial class MainWindow : Window
{
private SqlConnection connection;
private string dbName = string.Empty;
public MainWindow()
{
InitializeComponent();
LoadData();
}
private void LoadData()
{
try
{
string connectionString = "Data Source=localhost;Initial Catalog=Test_DB;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string query = "SELECT * FROM dbo.MachineAreas";
SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
gridMachineAreas.ItemsSource = dataTable.DefaultView;
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
private void GridMachineAreas_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
{
switch ((e.Column as GridViewDataColumn).DataMemberBinding.Path.Path)
{
case "ID":
var newColumn1 = new GridViewDataColumn();
newColumn1.CopyPropertiesFrom(e.Column);
newColumn1.Header = "ID";
newColumn1.Width = 60;
e.Column = newColumn1;
break;
case "Country":
var newColumn2 = new GridViewComboBoxColumn();
newColumn2.CopyPropertiesFrom(e.Column);
newColumn2.Header = "Country";
newColumn2.Width = 60;
newColumn2.UniqueName = "Country";
newColumn2.IsComboBoxEditable = false;
newColumn2.ItemsSource = MakeCountryCollection();
e.Column = newColumn2;
break;
case "Plant":
var newColumn3 = new GridViewComboBoxColumn();
newColumn3.CopyPropertiesFrom(e.Column);
newColumn3.Header = "Plant";
newColumn3.Width = 60;
e.Column = newColumn3;
break;
case "Area":
var newColumn4 = new GridViewComboBoxColumn();
newColumn4.CopyPropertiesFrom(e.Column);
newColumn4.Header = "Area";
newColumn4.Width = 60;
e.Column = newColumn4;
break;
case "Machine":
var newColumn5 = new GridViewComboBoxColumn();
newColumn5.CopyPropertiesFrom(e.Column);
newColumn5.Header = "Machine";
newColumn5.Width = 60;
e.Column = newColumn5;
break;
}
}
private List<string> MakeCountryCollection()
{
List<string> countryCollection = new List<string>();
string query = "SELECT Country FROM dbo.MachineAreas Group By Country";
try
{
string connectionString = "Data Source=localhost;Initial Catalog=Test_DB;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(query, connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
string value = reader.GetString(0);
countryCollection.Add(value);
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
return countryCollection;
}
}
Hello, Telerik
I want to create a feature with the following characteristics:
1. Use of the MVVM pattern.
2. The number of columns in the DataGridView is not fixed but dynamic. (Users can specify the number of columns as an option, allowing for dynamic changes.)
3. Only the first column's text is fixed, while the 2nd to nth columns are ComboBoxes, allowing users to select which columns they want to view.
For example, if a class has (name, age, gender, department, major, student number, average grade, highest grade, lowest grade) as fields,
'Name' is always shown in the first column as fixed data.
'Age' to 'Lowest Grade' are available as ComboBox options for users to select and view as they wish.
If n = 5, it could be displayed as follows:
1st | 2nd | 3rd | 4th | 5th
Name (Fixed) | Age | Gender | Major | Avg Score
or
1st | 2nd | 3rd | 4th | 5th
Name (Fixed) | Major | Avg Score | Max Score | Min Score
In this way, users can view data in the columns of their choice.
As mentioned, since the number of columns is dynamic, I don't want to write the column code as below.
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="column 1" DataMemberBinding="{Binding data_1}"/>
<telerik:GridViewDataColumn Header="column 2" DataMemberBinding="{Binding data_2}"/>
<telerik:GridViewDataColumn Header="column .." DataMemberBinding="{Binding data_1}"/>
<telerik:GridViewDataColumn Header="column n" DataMemberBinding="{Binding data_n}"/>
</telerik:RadGridView.Columns>
I searched all the SDK examples and forums, but I don't know how to write it.
Thank you in advance.
Hi,
We have an old application (VB6) that we are migrating to WPF and .NET 8. I use your WPF controls in this application. We use this application to creat test templates for different instruments.
Each test template consists of one or more subtest templates. Each subtest template consists of a test grid with different number of rows and columns, depending of instrument and type of test.
The subtest template grids data is stored in a database. Each subtest are stored in one table, each column number is stored in one table with foreign key to the subtest table, each cells value and row number is stored in one table with foreign key to the column table.
So far I have managed read data to my gridview with the help of your article https://docs.telerik.com/devtools/wpf/controls/radgridview/how-to/use-mixed-clr-dlr-properties.
First question,
I want the 4 first rows to be comboboxes, different combobox data for each row. I have been able to get comboboxes with DataTempletSelector, DataTemplate and RadGridView_AutoGeneratingColumn,
with help from this forum post from Petar Mladenov https://www.telerik.com/forums/unable-to-use-datatemplates-with-gridview-dynamic-data-not-even-with-icustomtypeprovider.
But my problem is that I don't get any data in the comboboxes. So how should I define my combobox so it databinds to my collection of comboboxdata?
Second question,
If I manage to fill the comboxes with data I don't know how to databind selectedvalue to my ObservableCollection<MyDataRow>, so how can I do that?
The rest of the gridcells are textboxes and they databinds automatically and updates my ObservableCollection<MyDataRow> when I change a value in a cell.
This is my gridview,
<telerik:RadGridView x:Name="TestCasesGridView"
ItemsSource="{Binding SubtestTestCases, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, BindsDirectlyToSource=True}"
IsFilteringAllowed="False"
CanUserSortColumns="False"
ShowColumnHeaders="True"
ShowSearchPanel="True"
SearchMode="MatchAllTerms"
SearchPanelCloseButtonVisibility="Collapsed"
IsSynchronizedWithCurrentItem="False"
AutoGenerateColumns="True"
AutoGeneratingColumn="RadGridView_AutoGeneratingColumn"
Margin="10"
IsReadOnly="False"
ShowGroupPanel="False"
RowIndicatorVisibility="Collapsed"
Height="Auto"
Width="Auto"
ScrollMode="Deferred"
ClipboardCopyMode="Default"
ClipboardPasteMode="AllSelectedRows"
SelectionMode="Single"
SelectionUnit="FullRow"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
CanUserSelectColumns ="False"
GroupRenderMode="Flat">
<telerik:RadGridView.Columns>
<helper:MyColumn Header="#"
Width="30" TextAlignment="Center"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.Resources>
<helper:MyCellTemplateSelector x:Key="myCellTemplateSelector">
<helper:MyCellTemplateSelector.ColumnNames>
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding ColumnNames}" DisplayMemberPath="KBE_Ben" OpenDropDownOnFocus="True"/>
</DataTemplate>
</helper:MyCellTemplateSelector.ColumnNames>
<helper:MyCellTemplateSelector.ColumnUnit>
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding ColumnUnits}" DisplayMemberPath="KEN_Kod" OpenDropDownOnFocus="True"/>
</DataTemplate>
</helper:MyCellTemplateSelector.ColumnUnit>
<helper:MyCellTemplateSelector.ColumnInfo>
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding ColumnInfos}" DisplayMemberPath="INF_InfoRad" OpenDropDownOnFocus="True"/>
</DataTemplate>
</helper:MyCellTemplateSelector.ColumnInfo>
<helper:MyCellTemplateSelector.ColumnProperty>
<DataTemplate>
<telerik:RadComboBox ItemsSource="{Binding ColumnProperties}" DisplayMemberPath="KEG_Namn" OpenDropDownOnFocus="True"/>
</DataTemplate>
</helper:MyCellTemplateSelector.ColumnProperty>
</helper:MyCellTemplateSelector>
</telerik:RadGridView.Resources>
</telerik:RadGridView>
Dear Support Team,
I am using the RadGridView in my application for view and data modification. I would like to add Combobox editor in particular cell based on condition in single column. I cannot find such solution in documentation.
If it is possible then How can i bind the item source to that particular Combobox editor?
Kindly provide example so I can implement in my project.
Thanks & Regards,
Hiren Lad
Hi Team,
I joined the project attaching Telerik.2020.2.617.45 version.
but I can download only 2023.xx version.
So How can i download 2020.2.617.45 version.
We use RadCombobox (WPF) for loading more than 20000 items.
We enabled the following properties and removed the Virtualization properties. We are facing performance problems on searching the items from RadCombobox element. How can we improve performance for the RadCombobox load and search, if virtualization properties cannot be used.
<telerik:RadComboBox