Telerik Forums
UI for WinForms Forum
5 answers
1.7K+ views
The default style does not gray out the image on a button that is disabled.

But there are other themes that do gray out the image (such as Desert, Breeze).

I'm making a copy of the default style and making small adjustments.  How can I make my custom theme use a gray image for a button that is disabled?
Stefan
Telerik team
 answered on 29 Feb 2012
3 answers
138 views
Hello,
I was hoping to have the ability to Update my RadGrid from a GidViewDetailElement that was implemented as a User Control. When a user clicks on a row in the RadGrid, a separate UserControl is displayed to show the Details of that Row.  I want to have the ability for the User to change a value in one of the fields shown in the Details vVew which will ujpdate the row in the base RadGrid. The code was implemented just like your example of "Custom Views" only that i wrapped the Details view as a User Control in a RadHostItem.  I'm able to view the data just fine in the User Control, its just not apparent to me how to now pass updates from this UserControl now back to my RadGrid with this GridViewDetailElement implementation or if its even possible.  Appreciate anyone who can help on this.  Thanks - Doug

i Have included the main pieces of code in how this was implemented.
Here is the code in my MainForm.c file that defines the detailView GridViewDetailElement for my RadGrid rgDetails.
private void InitializeGridControl()
        {
            this.rgDetails.TableElement.SetValue(DockLayoutPanel.DockProperty, Telerik.WinControls.Layouts.Dock.Top);
            this.rgDetails.TableElement.Margin = new Padding(10, 0, 10, 10);
            this.detailView = new GridViewDetailElement();
            this.rgDetails.GridViewElement.Panel.Children.Insert(1, this.detailView);
            this.detailView.SetValue(DockLayoutPanel.DockProperty, Telerik.WinControls.Layouts.Dock.Bottom);
            this.detailView.Margin = new Padding(10, 0, 10, 2);
        }


Here is the Class that Defines the GridViewDetailElement (just the relevant code).
public class GridViewDetailElement : GridVisualElement, IGridView
    {
        private RadGridViewElement gridElement;
        private GridViewInfo viewInfo;
        public DetailElement detailPanel;
  
        #region Fields
  
        private RadHostItem hostDetailView;
  
        #endregion
  
        #region Initialization
  
        protected override void InitializeFields()
        {
            base.InitializeFields();
  
            this.UseNewLayoutSystem = true;
            this.Padding = new System.Windows.Forms.Padding(10);
            this.StretchHorizontally = true;
            this.MinSize = new Size(0, 250);
            this.MaxSize = new Size(0, 250);
            this.DrawFill = true;
            this.Class = "RowFill";
            this.detailPanel = new DetailElement();
        }
  
        protected override void CreateChildElements()
        {
            base.CreateChildElements();
            hostDetailView = new RadHostItem(detailPanel);
            this.Children.Add(hostDetailView);
        }
  
public void Initialize(RadGridViewElement gridElement, GridViewInfo viewInfo)
        {
            this.gridElement = gridElement;
            this.viewInfo = viewInfo;
            this.gridElement.GridControl.CurrentRowChanged += new CurrentRowChangedEventHandler(GridControl_CurrentRowChanged);
        }
  
        public void Detach()
        {
            this.gridElement.GridControl.CurrentRowChanged -= new CurrentRowChangedEventHandler(GridControl_CurrentRowChanged);
            this.gridElement = null;
            this.viewInfo = null;
        }
  
public void UpdateView()
        {
            GridViewDataRowInfo dataRow = this.GridViewElement.GridControl.CurrentRow as GridViewDataRowInfo;
  
            if (dataRow != null)
            {
                detailPanel.UpdateUCView(dataRow);
            }
        }
  
        public RadGridViewElement GridViewElement
        {
            get { return this.gridElement; }
        }
  
        public GridViewInfo ViewInfo
        {
            get { return this.viewInfo; }
        }
  
        #endregion
  
        #region Event Handlers
  
        private void GridControl_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
        {
            this.UpdateView();
        }
  
        #endregion
     ...
}

And Here is my UserControl Code (relevant code only)

public partial class DetailElement : UserControl
    {
        public DetailElement()
        {
            InitializeComponent();
        }
 
        public void UpdateUCView(GridViewDataRowInfo dataRow)
        {
            string statusView;
            if (dataRow != null)
            {               
                statusView = GetSafeString(dataRow.Cells["State"].Value.ToString());
                switch (statusView)
                {
                    case "Running":
                        picBoxStatus.Image = Properties.Resources.start24;
                        break;
                    case "Paused":
                        picBoxStatus.Image = Properties.Resources.pause24;
                        break;
                    case "Stopped":
                        picBoxStatus.Image = Properties.Resources.stop_red24;
                        break;
                    default:
                        picBoxStatus.Image = Properties.Resources.warning16;
                        break;
                } 
                this.rTxtServiceOwner.Text = GetSafeString(dataRow.Cells["StartName"].Value.ToString());
                this.rTxtServiceType.Text = GetSafeString(dataRow.Cells["ServiceType"].Value.ToString());
                ....
         }
 
private void rChkTrackService_Click(object sender, EventArgs e)
        {
        // How Do I pass an update from this CheckBox back to my main Grid ???????????????
        }
}

Thanks Doug


Ivan Petrov
Telerik team
 answered on 29 Feb 2012
3 answers
215 views
Hi,

I've been playing around now for several hours with the question: What would be the best way to highlight a sentence? Keep in mind some sentences end with  "?" or "..."  By clicking on a button I would like the next sentence to be highlighted. Has anyone worked on this? 

Here's a code I have been working with. However, it only highlights the last word of a sentence, but not the last entire sentence.
    private void radButtonElement1_Click(object sender, EventArgs e)
    {
        this.radRichTextBox1.ChangeTextHighlightColor(System.Drawing.Color.White);
        this.radRichTextBox1.Document.Selection.Clear();
        this.radRichTextBox1.Document.Selection.AddSelectionStart(myNewSentenceStartPos);
        myEndPos.MoveToCurrentWordEnd();
        do
        {
            string word = myStartPos.GetCurrentSpanBox().Text;
            if (word.Contains("."))
            {
                DocumentPosition wordEndPosition = new DocumentPosition(myStartPos);
                wordEndPosition.MoveToCurrentWordEnd();
                this.radRichTextBox1.Document.Selection.Clear();
                this.radRichTextBox1.Document.Selection.AddSelectionStart(myNewSentenceStartPos);
                this.radRichTextBox1.Document.Selection.AddSelectionEnd(wordEndPosition);
                this.radRichTextBox1.ChangeTextHighlightColor(System.Drawing.Color.Aqua);  
                myStartPos = myEndPos;
                myNewSentenceStartPos = myEndPos;
                break;
            }
            else { }
        }
        while (myStartPos.MoveToNextWordStart());  
}

How can I set the start of the selection to myNewSentenceStartPos ?


Thank you,
Karl
Stefan
Telerik team
 answered on 29 Feb 2012
7 answers
790 views
I am still using a trial version of GridView to get an idea how powerful the control is. So, far everything is going good except I have no idea how to handle following situation.
The data is as follow

stock1 B 15
stock1 S 45
stock1 B 67
stock1 S  2

Where S-Sell and B-Buy. While grouping on column 1 (stock1) I need to display the position in stock1. But to do that while summing up the result the sell qty should be considered negative. How can I customize this sum operation?

Mitul
Nikolay
Telerik team
 answered on 29 Feb 2012
1 answer
175 views
It seems the rich text box is crashing when I try to open a docx document with tables. I couldn't attach a document which throws this error (because the web page doesn't allow docx files), but I can send it to someone interested in this error.

Here is the crash report:

System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.StyleRepository.EvaluateProperty[T](Style elementStyle, Style parentStyle, Object propertyKey, T defaultValue)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.StyleRepository.EvaluateProperty[T](Style elementStyle, Object propertyKey, T defaultValue)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.ParagraphImporter.ApplyStyle(Paragraph paragraph, StyleRepository styleRepository, Style style)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.TableImporter.ApplyBlockStyle(TableCell cell, Style style)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.TableImporter.ApplyConditionalStyle(TableCell cell, TableStyleConstrains availableStyles, Int32 currentRowIndex, Int32 currentColumnIndex)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.TableImporter.ApplyConditionalStyle(Table table, Style style)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.TableImporter.Import(Style parentStyle)

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.MainDocumentImporter.BuildBody()

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.MainDocumentImporter.BuildDocument()

   bei Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.Import.DocxImporter.Import()

   bei TelerikEditor.MainForm.OpenDocument()

   bei Telerik.WinControls.UI.BackstageButtonItem.OnClick(EventArgs e)

   bei Telerik.WinControls.RadItem.DoClick(EventArgs e)

   bei Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)

   bei Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)

   bei Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)

   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

   bei System.Windows.Forms.Control.WndProc(Message& m)

   bei Telerik.WinControls.RadControl.WndProc(Message& m)

   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

Boryana
Telerik team
 answered on 28 Feb 2012
1 answer
117 views
Does anyone trying to append programmatically some text at the end of an existing RadDocument?

This part of code doesen't works well:

Telerik.WinControls.RichTextBox.FormatProviders.IDocumentFormatProvider p = new Telerik.WinControls.RichTextBox.FileFormats.Html.HtmlFormatProvider();
Telerik.WinControls.RichTextBox.Model.RadDocument document = p.Import(System.Text.Encoding.UTF8.GetBytes(pBody));
document.CaretPosition.MoveToLastPositionInDocument();
document.InsertLineBreak();
document.Insert(pNote, style);
 
The text was appended at the end of the first word of the document.
Anyone could help me?

Thanks
  Francesco
Stefan
Telerik team
 answered on 28 Feb 2012
4 answers
524 views
Hi there,

I have a grid which is used for data entry and uses the New Row button.
I have set MasterTemplate.AddNewBoundRowBeforeEdit set to true so that the data is ready to be saved to the database on every cellEndEdit.

It looks like the new row still is not added to the data source until you leave that row by pressing up or down.

I need the new row added to the data source on the very first CellEndEdit. I need this because i have other controls on the form which react to rows being added.

I can use a SendKeys hack to achieve the desired result:

protected void CellEndEdit(object sender, GridViewCellEventArgs e)
{
    Save(e.Row.DataBoundItem);
 
    if (e.Row is GridViewNewRowInfo)
    {
        Debug.WriteLine("Attempting refresh");
        SendKeys.Send("{UP}");
    }
}


with this code i can edit a cell, press tab, and i end up on the next cell and the new row button appears below the current row.

Do you know of a better way to produce the same result ?
I've tried GridNavigator.SelectPreviousRow(1) in both CellEndEdit and CellValueChanged and it does nothing.

Thanks,
Matt
Matthew
Top achievements
Rank 1
 answered on 28 Feb 2012
2 answers
227 views
Hi,
I have implemented the 'Check All Header Cell' as shown in this KB article http://www.telerik.com/support/kb/winforms/gridview/add-check-uncheck-all-check-box-in-the-header-cell.aspx.

This works really well in most scenarios but I have run into a small bump in the road. The problem is that I have two grids that are linked in a cascading style. The purpose of this is to fill grid 2 with all of the contacts relating to the selected person or people in grid 1. Again this is all working perfectly for single or multiple selections using the normal check boxes in the rows.

I am hooking in to the ValueChanged event and then checking the cell type to determine if it is a single or check all operation. I set a processing flag to avoid multiple runs of the population code. The flag is reset in the DataBindingComplete event.

private void PupilGrid_ValueChanged(object sender, EventArgs e)
        {
            //set a processing flag as if the select all checkbox is used this
            //event fires for every checkbox in the column!
            if (_populatingParentGrid) return;
 
            _populatingParentGrid = true;
 
            if (sender.GetType() == typeof(GridViewCellInfo))
            {
                //this means the select all box has been checked
                RefreshParentGrid(true);
            }
            else if (sender.GetType() == typeof(RadCheckBoxEditor))
            {
                //single box checked
                RefreshParentGrid(false);
            }
        }
 
private void ParentGrid_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e)
        {
            //reset processing flag
            _populatingParentGrid = false;
            //PupilGrid.Enabled = true;        }

The problem I am getting is that the databinding is so fast that the flag is reset almost instantly. The 'Check All' code from the KB article  works by setting each checkbox to checked in a loop. This is firing the ValueChanged event and running the Grid 2 population code over and over again resulting in a lengthy delay (30 secs +) when the header cell is clicked.

I need a way to notify my app that the 'Check All' operation has finished (that is all of the check boxes have had their state changed and there are no other ValueChanged events to be raised). The following method from CheckBoxHeaderCell.cs is where I would expect see an event being raised from, but I cannot figure out a way to hook such an event from my app or make it bubble up via the grid.

private void checkbox_ToggleStateChanged(object sender, StateChangedEventArgs args)
        {
            if (suspendProcessingToggleStateChanged) return;
            bool valueState = false;
 
            if (args.ToggleState == ToggleState.On)
            {
                valueState = true;
            }
            GridViewElement.EditorManager.EndEdit();
            TableElement.BeginUpdate();
 
            foreach (GridViewRowInfo t in ViewInfo.Rows)
            {
                t.Cells[ColumnIndex].Value = valueState;
            }
 
            TableElement.EndUpdate(false);
 
            TableElement.Update(GridUINotifyAction.DataChanged);
 
            //Need to raise an event here to say that the processing has finished
        }

I add the column to my grid using the following code, I have checked the events available to 'checkColumn' and there is nothing suitable that I can see.

private void AddCheckColumn()
       {
           //Telerik code - see above for link
           var checkColumn = new CustomCheckBoxColumn {Name = "Select", HeaderText = "All", ReadOnly = false};
           //No suitable events found here
           PupilGrid.Columns.Insert(0, checkColumn);
           var checkColumn2 = new CustomCheckBoxColumn {Name = "Select", HeaderText = "All", ReadOnly = false};
           ParentGrid.Columns.Insert(0, checkColumn2);
       }


Can you please let me know if there is a way to raise an event from this custom header cell that can be hooked into by my app.

Many Thanks

Chris

Svett
Telerik team
 answered on 27 Feb 2012
4 answers
179 views
Hi,
Can you please advice how to remove the extra space as highlighted in RED box?
Thanks.
Yip Yew Kwong
Top achievements
Rank 1
 answered on 27 Feb 2012
2 answers
190 views
Hi,

I am having trouble with the first value displayed in a dropdownlist. The column is bound to a datasource that contains all possible values in the forms load event. Under the cell editor initialized event I change the drop down list editor element's datasource to only show relevant values based on another columns value. This is all working fine with correct values being populated in the list. However if I select the first value in the drop down list it does not display. All the other values work as expected.

 

Load event:
Dim ListDisplayColumn As GridViewComboBoxColumn = dgvReportingIndicators.Columns("ListSwitchDisplay")
            ListDisplayColumn.DataSource = Me.TrafficLightIndicatorsTableAdapter.GetData
            ListDisplayColumn.DisplayMember = "DisplayName"
            ListDisplayColumn.FieldName = "ListSwitch"
            ListDisplayColumn.ValueMember = "ID"

CellEditorInitialized event:
If e.Column.Name = "ListSwitchDisplay" Then
                Dim dropDownEditor = TryCast(dgvReportingIndicators.ActiveEditor, RadDropDownListEditor)
                Dim element = TryCast(dropDownEditor.EditorElement, RadDropDownListEditorElement)
                Select Case e.Row.Cells("IndicatorTypeDisplay").Value
                    Case "Count"
                        element.DataSource = Me.TrafficLightIndicatorsTableAdapter.GetNotApplicable
                    Case "Traffic Light"
                        element.DataSource = Me.TrafficLightIndicatorsTableAdapter.GetTL
                End Select
                element.ShowPopup()
            End If
Justin
Top achievements
Rank 1
 answered on 26 Feb 2012
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Form
Chart (obsolete as of Q1 2013)
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
Wizard
TextBoxControl
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
WaitingBar
GroupBox
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
NavigationView
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
TreeMap
StepProgressBar
SplashScreen
Flyout
Separator
SparkLine
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?