Please, can you help me with this question:
I have a grid with combobox column. All of these comboboxes have different DataSorce property (assigned thouth intercepting CellEditorInitialized event):
| Private Sub gridSort_CellEditorInitialized(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gridSort.CellEditorInitialized |
| Dim i As Integer |
| If gridSort.CurrentColumn.HeaderText = "Order" Then |
| Dim editor As Telerik.WinControls.UI.RadComboBoxEditor = gridSort.ActiveEditor |
| Dim editorElement As Telerik.WinControls.UI.RadComboBoxEditorElement = editor.EditorElement |
| If gridSort.Rows.IndexOf(gridSort.CurrentRow) = 1 Then |
| i = editorElement.SelectedIndex |
| editorElement.DataSource = New String() {"Minimized", "Maximized"} |
| editorElement.SelectedIndex = i |
| If i < 0 Then |
| Dim ii As Integer = 0 |
| For Each ss As String In editorElement.DataSource |
| If ss = gridSort.CurrentRow.Cells.Item(1).Value Then |
| editorElement.SelectedIndex = ii |
| Exit For |
| End If |
| ii += 1 |
| Next |
| End If |
| Else |
| i = editorElement.SelectedIndex |
| editorElement.DataSource = New String() {"Ascending", "Descending"} |
| editorElement.SelectedIndex = i |
| End If |
| End If |
| End Sub |
1. Every time editorElement.SelectedIndex have value -1 (and I must set value by searching throuh DataSource list and comparing with cell Value). For values Minimized/Maximized it's done and work fine, but for values Ascending/Descending it's not and when I click on combobox field - it's filled by empty sring.
Comparing with Value of cell is not fine because here can be some duplicated values (sic!) and I can not determine what value was in this cell before. Is here some method of determine SelectedIndex after changing of value?
2. I want to collect data choosen by user. But ComboBox cell in grid have not SelectedIndex (or I can not find it?) and I must to obtain it from Value property. Problem is similiar with previous question - how can I find a real position of value in DataSource list?
| Imports Telerik.WinControls |
| Imports Telerik.WinControls.UI |
| Imports System.Text |
| Imports System.Data.Common |
| Imports System.ComponentModel |
| Public Class Form1 |
| Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| Dim Item As GridMenuItem = New GridMenuItem |
| Dim Grid As RadGridView = Item.Grid |
| Grid.Columns.Add(New GridViewDataColumn("A")) |
| Grid.Columns.Add(New GridViewDataColumn("b")) |
| Grid.Columns.Add(New GridViewDataColumn("c")) |
| Grid.Rows.Add("Hello", "World", "!") |
| Grid.Rows.Add("Hello", "World", "!") |
| Grid.Rows.Add("Hello", "World", "!") |
| Grid.ReadOnly = False |
| Grid.Columns(0).Width = 5 |
| Grid.Columns(1).ReadOnly = True |
| Grid.Columns(2).IsVisible = False |
| RadDropDownButton1.Items.Clear() |
| RadDropDownButton1.Items.Add(Item) |
| End Sub |
| End Class |
Here's the item:
| Imports Telerik.WinControls.UI |
| Imports Telerik.WinControls |
| Imports System.ComponentModel |
| Public Class GridMenuItem |
| Inherits RadMenuItemBase |
| Implements INotifyPropertyChanged |
| Dim _Grid As RadGridView |
| Dim _HostItem As RadHostItem |
| Public ReadOnly Property Grid() As RadGridView |
| Get |
| Return Me._Grid |
| End Get |
| End Property |
| Protected Overrides Sub CreateChildElements() |
| _Grid = New RadGridView() |
| _Grid.BeginInit() |
| _Grid.BindingContext = New BindingContext() |
| _Grid.MultiSelect = True |
| _Grid.AutoSize = False |
| _Grid.HideColumnChooser() |
| _Grid.ReadOnly = False |
| _Grid.ShowGroupPanel = False |
| _Grid.ShowNoDataText = False |
| Dim Template As GridViewTemplate = _Grid.MasterGridViewTemplate |
| Template.AllowCellContextMenu = False |
| Template.AllowColumnChooser = False |
| Template.AllowColumnHeaderContextMenu = False |
| Template.AllowColumnReorder = False |
| Template.AllowAddNewRow = False |
| Template.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill |
| Template.EnableGrouping = False |
| Template.ShowFilteringRow = False |
| Template.ShowRowHeaderColumn = False |
| Template.ShowColumnHeaders = False |
| _Grid.EndInit() |
| _HostItem = New RadHostItem(_Grid) |
| Me.Children.Add(_HostItem) |
| End Sub |
| Protected Overrides Function MeasureOverride(ByVal availableSize As System.Drawing.SizeF) As System.Drawing.SizeF |
| Dim size As System.Drawing.SizeF = MyBase.MeasureOverride(availableSize) |
| Return _Grid.Size |
| End Function |
| End Class |
| GridViewComboBoxColumn stockCode = new GridViewComboBoxColumn(); |
| stockCode.DataSource = dbS.view_Trans_Order_StockCodes; |
| stockCode.DisplayMember = "StockCode"; |
| stockCode.ValueMember = "StockCode"; |
| stockCode.FieldName = "StockCode"; |
| stockCode.AutoCompleteMode = AutoCompleteMode.Suggest; |
| radGridView1.MasterGridViewTemplate.Columns.Add(stockCode); |
RadChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 45
RadChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.LongDate
RadChart1.PlotArea.XAxis.DataLabelsColumn = "OrderDate"
RadChart1.DataSource = dtOrders
RadChart1.DataBind()
You've already probably guessed what my question is. This errors becuase I believe the OrderDate is not in the correct format and I need to us toAODate() in order to make this work. Great, how? Do I have to convert the data in the datatable with this function? How do you use it? I've looked at the microsoft page, it didn't shed any light for me.
I understand that;
Dim SomeDateAsADouble as Double
DatetoConvert as Date = Today()
SomeDateAsADouble = DatetoConvert.ToAODate()
How does this help with the above problem?
RadChart1.PlotArea.XAxis.DataLabelsColumn = "OrderDate".ToAODate() ;This won't work
Please can someone help me, and anyone after me with an explained solution. I really would appreciate it.