Hi,
When I "left click" on a header of a page, the page is changed before I release the mouse click.
Also, when right clicking it's selecting/unselecting a page, it looks strange.
Before I override many things, how would you do to change this behavior in a clean way? We won't deactivate right-click because we do have context menu to save the opening tab on new view show.
Thanks a lot in advance!
Simon
Hi everyone,
I'm currently working with the RadRichTextEditor control in my C# WinForms application, and I need to customize the colors of the slide and background bar. Could someone guide me on the steps to change these colors? Additionally, if there's a way to achieve this directly through code, I'd greatly appreciate it if you could share a code snippet.
Thank you in advance for your help!
Best regards,
Kevin
Hi,
I saw that in GridView you can create a group for the column header (https://docs.telerik.com/devtools/winforms/controls/gridview/view-definitions/column-groups-view).
Is it possible to have the same feature in VirtualGrid?
I need something similar in the attached image. Just a simple group description without additional filters.
Thank you very much.
Emanuele
I have a data entry RadGridView bound to a collection of POCOs. It has some rather compiles editing requirements. On one particular row, there is a cell that requires the edit control to be a multi-selection combo box. On all other rows it requires a numeric entry. I created the column as a GridViewComboBoxColumn. and then tried to create a custom control to replace the standard editor using the EditorRequired event like this:
private void gvMatrix_EditorRequired(object sender, EditorRequiredEventArgs e)
{
if (gvMatrix.CurrentRow.Cells["Comparison"].Value.ToString() == "One of")
{
if (e.EditorType == typeof(CustomCheckedListBox))
e.EditorType = typeof(CustomCheckedListBox);
}
//Otherwise I need numeric entry
}
Then, I tried to create the custom control based on the example on the Telerik site (https://docs.telerik.com/devtools/winforms/controls/gridview/editors/using-custom-editors) and came up with this:
public class CustomCheckedListBox : BaseGridEditor
{
protected override RadElement CreateEditorElement()
{
return new CustomCheckedListBoxElement();
}
public override object Value
{
get
{
CustomCheckedListBoxElement element = this.EditorElement as CustomCheckedListBoxElement;
return element.CheckedDropDownElement.Value;
}
set
{
CustomCheckedListBoxElement element = this.EditorElement as CustomCheckedListBoxElement;
element.CheckedDropDownElement.Value = value;
}
}
public override void BeginEdit()
{
base.BeginEdit();
CustomCheckedListBoxElement element = this.EditorElement as CustomCheckedListBoxElement;
var statesData = new List<Dictionary>();
statesData.Add(new Dictionary { DictionaryKeyString = "AK", Description = "Alaska" });
statesData.Add(new Dictionary { DictionaryKeyString = "NJ", Description = "New Jersey" });
statesData.Add(new Dictionary { DictionaryKeyString = "AL", Description = "Alabama" });
statesData.Add(new Dictionary { DictionaryKeyString = "GA", Description = "Georgia" });
element.DataSource = statesData;
element.DropDownStyle = RadDropDownStyle.DropDownList;
element.ValueMember = "DictionaryKeyString";
element.DisplayMember = "Description";
}
public override bool EndEdit()
{
return base.EndEdit();
}
//public string? ValueMember { get; set; }
//public string? DisplayMember { get; set; }
//public object? DataSource { get; set; }
}
public class CustomCheckedListBoxElement : RadCheckedDropDownListElement
{
RadCheckedDropDownListElement dropDownListElement = new RadCheckedDropDownListElement();
public CustomCheckedListBoxElement()
{
}
public RadCheckedDropDownListElement CheckedDropDownElement
{
get => this.dropDownListElement;
}
protected override void CreateChildElements()
{
base.CreateChildElements();
}
}
What I get is a an empty dropdown in the cell with no data appearing. Ideally I'd like to instantiate the custom control and pass in the DataSource, ValueMember, etc. so I can reuse it elsewhere. The goal is to retrieve a list of selected states and display them like this when the cell is not in edit mode:
Alabama
New Jersey
Georgia
Any ideas on how to accomplish this?
Thanks
Carl
Hello,
is it possible to end edit when user navigates to other cell? The same behavior as standard DataGridView:
I tried to call EndEdit in CurrentCellChanged event handler, but it doesn't work, probably there is something with current cell changing, nor IsInEditMode is not set in this event.
Hello,
I would like to help with GridViewComboBoxColumn behavior. I have almost solved how to automatically show popup on click. Next, I want to end edit after selecting some item from combo box, similar to standard DataGridView behavior. I have done this so far:
private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
{
// automatic combo expanding
if (radGridView1.IsInEditMode)
return;
var cell = sender as GridComboBoxCellElement;
if (cell == null)
return;
radGridView1.BeginEdit();
var editor = cell.Editor as RadDropDownListEditor;
if (editor == null)
return;
var el = editor.EditorElement as RadDropDownListEditorElement;
if (el == null)
return;
el.SelectedIndexChanged += El_SelectedIndexChanged;
el.ShowPopup();
}
private void El_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
var el = sender as RadDropDownListEditorElement;
if(el == null)
return;
radGridView1.EndEdit();
el.SelectedIndexChanged -= El_SelectedIndexChanged;
}
I attach SelectedIndexChanged event handler to RadDropDownListEditorElement before showing popup. In this handler, I call EndEdit first and then detach the handler. This works ok except for one case, when user selects the same item, in this case SelectedIndexChanged is not fired, because SelectedIndex hasn't changed:
I tried the same with other events like PopupClosed, but when I cal EndEdit in these events, selected value is not commited. Is it possible to do this somehow? I have attached test project, TelerikTestReal in solution. Thanks.
Hello,
I would like to ask about DataError event once more (we discussed it a little in some previous thread). I have tested behavior and program crashes in case of parsing error. First, if I do some validation in underlying data object and throw exception in object property setter, GridView handles it corectly and fires DataError event. But in case of parsing error, for example when I have textbox column, integer property and enter some non-numeric text, program crashes with unhandled exception:
I know, I should use GridViewDecimalColumn, but generally, why GridView doesn't handle parsing error and doesn't fire DataError event also in this case? I have attached also the test project, TelerikTestDataError in solution.
Unhandled exception:
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.ComponentModel.BaseNumberConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
at Telerik.WinControls.UI.RadDataConverter.ParseCore(Object value, Type targetType, Type sourceType, TypeConverter dataTypeConverter, IDataConversionInfoProvider dataColumn, Boolean checkFormattedNullValue, CultureInfo cultureInfo)
at Telerik.WinControls.UI.RadDataConverter.Parse(IDataConversionInfoProvider converstionInfoProvider, Object value, CultureInfo cultureInfo)
at Telerik.WinControls.UI.GridDataCellElement.set_Value(Object value)
at Telerik.WinControls.UI.GridViewEditManager.EndEditCore(Boolean validate, Boolean cancel)
at Telerik.WinControls.UI.GridViewEditManager.EndEdit()
at Telerik.WinControls.UI.GridRowBehavior.ProcessEnterKey(KeyEventArgs keys)
at Telerik.WinControls.UI.GridRowBehavior.ProcessKey(KeyEventArgs keys)
at Telerik.WinControls.UI.BaseGridBehavior.ProcessKey(KeyEventArgs keys)
at Telerik.WinControls.UI.BaseGridBehavior.ProcessKeyDown(KeyEventArgs keys)
at Telerik.WinControls.UI.BaseGridEditor.OnKeyDown(KeyEventArgs keyEventArgs)
at Telerik.WinControls.UI.RadTextBoxEditor.OnKeyDown(KeyEventArgs e)
at Telerik.WinControls.UI.RadTextBoxEditor.TextBoxItem_KeyDown(Object sender, KeyEventArgs e)
at System.Windows.Forms.KeyEventHandler.Invoke(Object sender, KeyEventArgs e)
at Telerik.WinControls.RadItem.OnKeyDown(KeyEventArgs e)
at Telerik.WinControls.UI.RadTextBoxItem.TextBoxControl_KeyDown(Object sender, KeyEventArgs e)
at System.Windows.Forms.Control.OnKeyDown(KeyEventArgs e)
at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.WndProc(Message& m)
at Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
'Declaration Private contextMenu1 As RadContextMenu 'Page Load contextMenu1 = New RadContextMenu() Dim menuItem1 As New RadMenuItem("Export") menuItem1.ForeColor = Color.Red AddHandler menuItem1.Click, AddressOf rmi1_Click Dim menuItem2 As New RadMenuItem("Verification") AddHandler menuItem2.Click, AddressOf rmi2_Click contextMenu1.Items.Add(menuItem1) contextMenu1.Items.Add(menuItem2) 'Code for show context menu Private Sub RadGridView1_ContextMenuOpening(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.ContextMenuOpeningEventArgs) Handles RadGridView1.ContextMenuOpening e.ContextMenu = contextMenu1.DropDown End Sub 'Menu click event Private Sub rmi2_Click(sender As Object, e As EventArgs) sender.Visible = CDec(sender.Row.Cells("Status").Value) = "Export" End Sub Private Sub rmi1_Click(sender As Object, e As EventArgs) sender.Visible = CDec(sender.Row.Cells("Status").Value) = "Done" End Sub
Private Sub rmi1_Click(sender As Object, e As EventArgs) sender.Visible = CDec(sender.Row.Cells("Status").Value) = "Pending" End Sub
I have created a custom PropertyGridItemElement for my RadPropertyGrid to hold a button. When the user clicks the button, the click handler performs some action, but the action is based on data that is known by the form that contains the propertygrid that contains the custom element. How do I arrange for that data to be available to the button's Click handler? The constructor of the custom element isn't even called explicitly -- it's implicit in
PropertyGrid.CreateItemElement += (sender, args) =>
{
if (args.Item.Name == nameof(LabelWrapper.Button))
{
args.ItemElementType = typeof(CustomPropertyGridItemElement);
}
};
Thanks in advance.
public class Globals
{
public static Color DefaultTabColor = Color.FromArgb(255, 191, 219, 255);
}
...
private void CancelTab(int offset)
{
DetailTabControl.Pages[offset].Item.DrawFill = true;
DetailTabControl.Pages[offset].Item.NumberOfColors = 1;
DetailTabControl.Pages[offset].Item.BackColor = Color.Red;
}
private void UncancelTab(int offset)
{
DetailTabControl.Pages[offset].Item.BackColor = Globals.DefaultTabColor;
DetailTabControl.Pages[offset].Item.NumberOfColors = 2;
DetailTabControl.Pages[offset].Item.DrawFill = false;
}