Telerik Forums
UI for WinForms Forum
2 answers
144 views
 Hello,
I have hooked an event handler to the DockStateChanged event in order to intercept the tool windows that were being detached from the dock. Once I find a tool window whose DockState has turned to Floating I adjust its size and change the border style so that the user cannot resize it anymore while it is floating. However I encountered a small problem with this approach: if I detach the tool window by clicking its tab and dragging it out of the tab strip the FloatingParent field of the DockWindow provided in the event arguments is properly set and I can alter it. However if I double-click on the tab or use the context menu to make the window floating the FloatingParent field is set to null. Curiously this only happens the first time I undock the window this way, if I dock the window again and then undock it FloatingPanel is not null anymore (the same is true if I undock the window by dragging it out of the tab strip). Is this an intended behavior or a bug? Here's my event handler code (which throws a NullReferenceException when FloatingParent is null):

void event_DockStateChanged(object sender, DockWindowEventArgs e) 
    if (e.DockWindow.DockState == DockState.Floating) 
    { 
        // Resize a tool window to fit its contents and make it fixed-size. 
        e.DockWindow.FloatingParent.ClientSize = e.DockWindow.GetPreferredSize(Size.Empty); 
        e.DockWindow.FloatingParent.FormBorderStyle = FormBorderStyle.FixedToolWindow; 
    } 

Gabriele Svelto
Top achievements
Rank 1
 answered on 12 Feb 2010
1 answer
167 views
I have two DateTimePicker controls on a form that represent Start and End dates. I want the initially to be empty which I figured out how to do by assigning the value a database null value of 1/1/0001. The problem is that when I go to use the drop down the start date is 1/1/1900. Navigating all the way to current day is painful to the user.

Is there a way to assign the MinDate to a value like DateTime.Now but leave the value property empty? That would be the ideal scenario as my application does allow these fields to be unspecified.
Boyko Markov
Telerik team
 answered on 12 Feb 2010
6 answers
243 views
For more clear I recorded short video how it work www.8080.pl/download/dgv.wmv
I have radgridview with a datasource that is linking to a linq2sql:

TestowaBazaDataContext db = new TestowaBazaDataContext();  
 
      radGridView1.DataSource = db.tabelaZlecenias; 

When I insert a new record I want refresh the grid again:

private void radGridView1_RowsChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)  
    {  
      TestowaBazaDataContext db = new TestowaBazaDataContext();  
 
      if ((e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged) &&  
          ((int) radGridView1.Rows[e.NewStartingIndex].Cells["idZlecenia"].Value == 0))  
      {  
        //new record  
        if (radGridView1.Rows[e.NewStartingIndex].Cells["Zlecenie"].Value != null)  
        {  
          var nowa = new tabelaZlecenia()  
                       {  
                         Zlecenie = (int) radGridView1.Rows[e.NewStartingIndex].Cells["Zlecenie"].Value  
                       };  
          db.tabelaZlecenias.InsertOnSubmit(nowa);  
          db.SubmitChanges();         
 
      TestowaBazaDataContext dbZ = new TestowaBazaDataContext();  
      radGridView1.DataSource = dbZ.tabelaZlecenias;
 
        }  
      }  
    } 
 
But I see only error.
If I call if from button's event and it work correctly:

    private void button1_Click(object sender, EventArgs e)  
    {  
      //I need refresh data by Linq in radGridView1  
      TestowaBazaDataContext dbZ = new TestowaBazaDataContext();  
      radGridView1.DataSource = dbZ.tabelaZlecenias;  
    } 

But I need automatic refresh after I added records. How and where I can do it?
Robert Stuczynski
Top achievements
Rank 1
 answered on 12 Feb 2010
5 answers
265 views
I am using the rad panel to hold items that may scroll.  I would like to skin the scrollbars that are in the rad panel much like the vertical and horizontal scrollbars allow.  Is this possible?
Deyan
Telerik team
 answered on 12 Feb 2010
1 answer
82 views
The following works;
GridGroupByExpression groupBy = new GridGroupByExpression();
groupBy.Expression = "[Status] format \"Current {0}: {1}\" Group By Status DESC";
this.fundsGrid.MasterGridViewTemplate.GroupByExpressions.Add(groupBy);

The following doesnt work

GridGroupByExpression groupBy = new GridGroupByExpression();
groupBy.Expression = "[Status] format \"Current {0}: {1}\" Group By Status desc";
this.fundsGrid.MasterGridViewTemplate.GroupByExpressions.Add(groupBy);

:o)
Julian Benkov
Telerik team
 answered on 12 Feb 2010
7 answers
197 views
A RadForm based application will crash (unhandled exception) if any accent key ( ^ , ´ , ` ) is pressed.

You can easily reproduce this with the telerik WinForms demos:
* Run the Telerikt Examples demo application
* Then open for example
  * Integration -> Themes Color Blending
  * Integration -> File Explorer and focus the grid on the right but don't enter edit mode
  * Forms & Dialogs -> RadForm First Look
  * or GridView -> Hierarchy and focus any grid but don't enter edit mode
* hit any accent key (e.g. ^)

The application will in best case show an "Unhandled exception" dialog - or crash completely like the RadForms First Look.

For us this is a critical bug as we develop a crucial inhouse system - and the users often need accent keys (for typing french names for example). But they earn crashes all the way...

Regards,
ReneMT
Deyan
Telerik team
 answered on 11 Feb 2010
4 answers
237 views
Hello,
I have encountered this exception when handling KeyPress event. I am from Czech Republic and we have specific characters, for example: ˇ - it's KeyChar 711 (examining KeyPressEventArgs in standard GridView control which lacks the bug). However when trying to type this character on RadGridView the exception is thrown.

The only solution that I can think of right now is overriding PreProcessMessage or ProcessDialogKey on RadGridView subclass - so not allowing the characters to be passed to the application (so as not to get the exception) I have not try it just yet though.

System.OverflowException was unhandled
  Message="Value was either too large or too small for an Int32."
  Source="mscorlib"
  StackTrace:
       v System.Convert.ToChar(Int32 value)
       v Telerik.WinControls.UI.BaseGridBehavior.ProcessAlphaNumericKey(KeyEventArgs keys)
       v Telerik.WinControls.UI.BaseGridBehavior.ProcessKey(KeyEventArgs keys)
       v Telerik.WinControls.UI.RadGridView.ProcessDialogKey(Keys keyData)
       v System.Windows.Forms.Control.PreProcessMessage(Message& msg)
       v System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
       v System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
       v System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg)
       v System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       v System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       v System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       v System.Windows.Forms.Application.Run(Form mainForm)
       v WindowsFormsApplication2.Program.Main() v C:\Users\nguyen\Documents\Visual Studio 2008\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:řádek 18
       v System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       v System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       v Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       v System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       v System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       v System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Jack
Telerik team
 answered on 11 Feb 2010
1 answer
341 views
Hello,
I have a Winforms RadCombo box for which I am attempting to set a class derived from CollectionBase as the DataSource. I find that the DisplayMember of the comboxbox is set to an empty string. The ValueMember retains the correct column setting.

Any help is really appreciated...

Here are the relevant pieces of code:

FixedBillingPackageList.cs
===============================
 public class FixedBillingPackageList : ReadOnlyCollectionBase
    {

        #region Data Structure
        [Serializable]
        public struct FixedBillingPackageListInfo
        {
            // This has private members, public properties because
            // ASP.NET can't data bind to public members of a structure
            private int _fixedBillingPackageID; //**PK
            private string _packageName;
            private decimal _rate;

            public int FixedBillingPackageID
            {
                get { return _fixedBillingPackageID; }
                set { _fixedBillingPackageID = value; }
            }

            public string PackageName
            {
                get { return _packageName; }
                set { _packageName = value; }
            }
            public decimal Rate
            {
                get { return _rate; }
                set { _rate = value; }
            }

            public string PackageNamePrice
            {
                get
                {
                    return String.Format("{0} ({1})", _packageName, _rate);
                }
            }
        }
        #endregion //Data Structure

       #region Data Access
        protected void Fetch(object criteria)
        {
            //retrieve data from database
            Criteria crit = (Criteria)criteria;
            Database database = DatabaseFactory.CreateDatabase("ConnectionString");
            DbCommand dbCommand = database.GetSqlStringCommand("SELECT FixedBillingPackage.FixedBillingPackageID AS FixedBillingPackageID, FixedBillingPackage.PackageName AS PackageName, FixedBillingPackage.Rate AS Rate FROM FixedBillingPackage ");
            dbCommand.CommandType = CommandType.Text;
            SafeDataReader dataReader = new SafeDataReader(database.ExecuteReader(dbCommand));
            try
            {
                // Insert Blank row at the top of the list if specified.
                if (crit.IncludeBlankRow)
                {
                    FixedBillingPackageListInfo info = new FixedBillingPackageListInfo();
                    info.FixedBillingPackageID = -1;
                    info.PackageName = String.Empty;
                    info.Rate = 0;
                    InnerList.Add(info);
                }

                while (dataReader.Read())
                {
                    FixedBillingPackageListInfo info = new FixedBillingPackageListInfo();
                    info.FixedBillingPackageID = dataReader.GetInt16(0);
                    info.PackageName = dataReader.GetString(1);
                    info.Rate = dataReader.GetDecimal(2);
                    InnerList.Add(info);
                }
            }
            finally
            {
                dataReader.Close();
                dataReader.Dispose();
            }
        }

        #endregion Data Access
    }

MainForm.cs
================
MainForm.cs
===============


public MainForm()
{
   InitializeComponent();
   INitializeData();
}

private void InitializeData()
{

            FixedBillingPackageList packageList = FixedBillingPackageList.GetFixedBillingPackageList(true);
            comboFixedBillingPackage.BindingContext = new BindingContext();
           
            this.comboFixedBillingPackage.DisplayMember = "PackageName";
            this.comboFixedBillingPackage.ValueMember = "FixedBillingPackageID";
            comboFixedBillingPackage.DataSource = packageList;
}
Victor
Telerik team
 answered on 11 Feb 2010
3 answers
163 views
Hi,
I'm getting into TPF based control development and I'm finding a lot of difficulties to understand the behind logic maybe because there is not enough documentation and examples on that.

I'm trying to make a control that arrange in a stacklayout many radlabelelement as the Rows property value of my control; the height of any child element should be control.Size.Height/control.Rows, so I got my child to have same height.

This is the way I implement it, could you please help me on that?

MyControl:
    public class MyControl : RadControl 
    { 
        MyElementPanel elementPanel; 
 
        public MyControl() 
        { 
            this.UseNewLayoutSystem = true
            this.AutoSize = true
        } 
 
        protected override void CreateChildItems(RadElement parent) 
        { 
            elementPanel = new MyElementPanel(); 
            this.RootElement.Children.Add(elementPanel); 
            base.CreateChildItems(parent); 
        } 
 
        public int Rows 
        { 
            get 
            { 
                return this.elementPanel.Rows; 
            } 
            set 
            { 
                this.elementPanel.Rows = value; 
            } 
        } 
 
    } 
 

MyElement:
    public class MyElementPanel : RadItem 
    { 
        StackLayoutPanel layout; 
 
        public static RadProperty RowsProperty = RadProperty.Register( 
            "Rows"
            typeof(int), 
            typeof(MyElementPanel), 
            new RadElementPropertyMetadata(2, ElementPropertyOptions.AffectsLayout)); 
 
        public int Rows 
        { 
            get 
            { 
                return (int)this.GetValue(RowsProperty); 
            } 
            set 
            { 
                this.SetValue(RowsProperty, value); 
            } 
        } 
 
        protected override void CreateChildElements() 
        { 
            var border = new BorderPrimitive(); 
            Children.Add(border); 
            var background = new FillPrimitive(); 
            Children.Add(background); 
 
            layout = new StackLayoutPanel(); 
            layout.Orientation = System.Windows.Forms.Orientation.Vertical; 
            this.Children.Add(layout); 
 
            var rows = this.Rows; 
            int rowHeight = (int)this.Size.Height / rows; 
            for (int i = 0; i < rows; i++) 
            { 
                var child = new RadLabelElement(); 
                child.Text = (i + 1).ToString(); 
                child.Margin = new System.Windows.Forms.Padding(1); 
                child.Children[2].AutoSize = false
                child.Children[2].Size = new Size(20, rowHeight); 
                child.BorderVisible = true
                layout.Children.Add(child); 
            } 
 
            base.CreateChildElements(); 
        } 
 
        protected override void OnPropertyChanged(RadPropertyChangedEventArgs e) 
        { 
            if (e.Property == StorageRackElement.RowsProperty) 
            { 
                var rows = (int)e.NewValue; 
                int rowHeight = (int)this.Size.Height / rows; 
                layout.Children.Clear(); 
                for (int i = 0; i < rows; i++) 
                { 
                    var child = new RadLabelElement(); 
                    child.Text = (i + 1).ToString(); 
                    child.Margin = new System.Windows.Forms.Padding(1); 
                    child.Children[2].AutoSize = false
                    child.Children[2].Size = new Size(20, rowHeight); 
                    child.BorderVisible = true
                    layout.Children.Add(child); 
                } 
            } 
            if (e.Property == StorageRackElement.BoundsProperty) 
            { 
                int rowHeight = (int)this.Size.Height / this.Rows; 
                foreach(var child in layout.Children) 
                    child.Children[2].Size = new Size(20, rowHeight); 
            } 
 
            base.OnPropertyChanged(e); 
        } 
    } 
 
Dobry Zranchev
Telerik team
 answered on 11 Feb 2010
0 answers
176 views
i created a radribbonform as a main form for my application. then i added 2 radform as mdichild of the main. i load the windowstate of the 2 mdichild to maximize. While 2 mdichild is open, i used a button to toggle between the 2. problem is, the windowstate of the child revert back to normal state.  i want the radform to show in maximize state. how can i fixed this? anyone?

Thanks,
jeff torririt
Top achievements
Rank 1
 asked on 11 Feb 2010
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
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
FileDialogs
ColorDialog
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
RibbonForm
Styling
Barcode
PopupEditor
TaskBoard
NavigationView
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
BreadCrumb
ButtonTextBox
FontDropDownList
BarcodeView
Overlay
Security
LocalizationProvider
Dictionary
SplashScreen
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
ToolbarForm
NotifyIcon
DateOnlyPicker
AI Coding Assistant
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
SpeechToTextButton
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?