Telerik Forums
UI for WinForms Forum
10 answers
1.9K+ views
I got a datetimepicker. Displaying short date format. If I do the size of the control to suit that format, the drop down showing the month is very small. User can use the handle in the bottom right corner to resize it, but I want it to show nicely to start with. Any way to do that other than increasing the width of the datetimepicker (which leave a lot of blank space to the right)?
Stefan
Telerik team
 answered on 26 Jun 2013
3 answers
187 views
I have a gridview bound to an BindingList<> and it allows the user to add a new row.  Whenever the user clicks on the add new row area, the grid immediately inserts 2 new rows  one of them overlaps the area with the prompt "Click here to add a new row".  Once the user is done editing one of the rows.  An IndexOutOfRangeException is thrown when the grid tries to set the value to the extra row.  How can I avoid this?

public NoteHistoryControl()
        {
            InitializeComponent();
            this.noteHistoryGridView.DataSource = new BindingList<Note>(this._noteHistory);
        }
 
 
        private void noteHistoryGridView_CellValueChanged(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
        {
            GridViewDataColumn column = e.Column as GridViewDataColumn;
            if (column != null && column.FieldName == "Text")
            {
                this._noteText = e.Value.ToString();
                this.noteHistoryGridView.MasterGridViewTemplate.AllowAddNewRow = false;
            }
        }

private void InitializeComponent()
        {
            Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            Telerik.WinControls.UI.GridViewDateTimeColumn gridViewDateTimeColumn1 = new Telerik.WinControls.UI.GridViewDateTimeColumn();
            Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn2 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
            Telerik.WinControls.UI.GridSortField gridSortField1 = new Telerik.WinControls.UI.GridSortField();
            this.panel1 = new System.Windows.Forms.Panel();
            this.noteLabel = new System.Windows.Forms.Label();
            this.noteHistoryGridView = new Telerik.WinControls.UI.RadGridView();
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.noteHistoryGridView)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.noteHistoryGridView.MasterGridViewTemplate)).BeginInit();
            this.SuspendLayout();
            //
            // panel1
            //
            this.panel1.Controls.Add(this.noteLabel);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Padding = new System.Windows.Forms.Padding(3);
            this.panel1.Size = new System.Drawing.Size(400, 28);
            this.panel1.TabIndex = 0;
            //
            // noteLabel
            //
            this.noteLabel.AutoSize = true;
            this.noteLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.noteLabel.Location = new System.Drawing.Point(6, 6);
            this.noteLabel.Margin = new System.Windows.Forms.Padding(3);
            this.noteLabel.Name = "noteLabel";
            this.noteLabel.Size = new System.Drawing.Size(44, 16);
            this.noteLabel.TabIndex = 1;
            this.noteLabel.Text = "Notes";
            //
            // noteHistoryGridView
            //
            this.noteHistoryGridView.BackColor = System.Drawing.SystemColors.Control;
            this.noteHistoryGridView.Cursor = System.Windows.Forms.Cursors.Default;
            this.noteHistoryGridView.Dock = System.Windows.Forms.DockStyle.Fill;
            this.noteHistoryGridView.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.noteHistoryGridView.ForeColor = System.Drawing.SystemColors.ControlText;
            this.noteHistoryGridView.ImeMode = System.Windows.Forms.ImeMode.NoControl;
            this.noteHistoryGridView.Location = new System.Drawing.Point(0, 28);
            //
            //
            //
            this.noteHistoryGridView.MasterGridViewTemplate.AddNewRowPosition = Telerik.WinControls.UI.PinnedRowPosition.Bottom;
            this.noteHistoryGridView.MasterGridViewTemplate.AllowColumnChooser = false;
            this.noteHistoryGridView.MasterGridViewTemplate.AllowColumnReorder = false;
            this.noteHistoryGridView.MasterGridViewTemplate.AllowDeleteRow = false;
            this.noteHistoryGridView.MasterGridViewTemplate.AllowDragToGroup = false;
            this.noteHistoryGridView.MasterGridViewTemplate.AllowEditRow = false;
            this.noteHistoryGridView.MasterGridViewTemplate.AutoGenerateColumns = false;
            this.noteHistoryGridView.MasterGridViewTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
            gridViewTextBoxColumn1.AllowFiltering = false;
            gridViewTextBoxColumn1.AllowGroup = false;
            gridViewTextBoxColumn1.AllowHide = false;
            gridViewTextBoxColumn1.FieldAlias = "columnNote";
            gridViewTextBoxColumn1.FieldName = "Text";
            gridViewTextBoxColumn1.HeaderText = "Note";
            gridViewTextBoxColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            gridViewTextBoxColumn1.MinWidth = 50;
            gridViewTextBoxColumn1.Multiline = true;
            gridViewTextBoxColumn1.UniqueName = "columnNote";
            gridViewTextBoxColumn1.Width = 215;
            gridViewTextBoxColumn1.WrapText = true;
            gridViewDateTimeColumn1.AllowFiltering = false;
            gridViewDateTimeColumn1.AllowGroup = false;
            gridViewDateTimeColumn1.AllowHide = false;
            gridViewDateTimeColumn1.DataType = typeof(System.DateTime);
            gridViewDateTimeColumn1.FieldAlias = "EntryDate";
            gridViewDateTimeColumn1.FieldName = "EntryDate";
            gridViewDateTimeColumn1.HeaderText = "Entry Date";
            gridViewDateTimeColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            gridViewDateTimeColumn1.MinWidth = 50;
            gridViewDateTimeColumn1.ReadOnly = true;
            gridViewDateTimeColumn1.UniqueName = "columnDate";
            gridViewDateTimeColumn1.Width = 215;
            gridViewTextBoxColumn2.AllowFiltering = false;
            gridViewTextBoxColumn2.AllowGroup = false;
            gridViewTextBoxColumn2.AllowHide = false;
            gridViewTextBoxColumn2.FieldAlias = "EntryUsername";
            gridViewTextBoxColumn2.FieldName = "EntryUsername";
            gridViewTextBoxColumn2.HeaderText = "Username";
            gridViewTextBoxColumn2.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
            gridViewTextBoxColumn2.MinWidth = 50;
            gridViewTextBoxColumn2.ReadOnly = true;
            gridViewTextBoxColumn2.UniqueName = "columnUsername";
            gridViewTextBoxColumn2.Width = 215;
            this.noteHistoryGridView.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn1);
            this.noteHistoryGridView.MasterGridViewTemplate.Columns.Add(gridViewDateTimeColumn1);
            this.noteHistoryGridView.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn2);
            this.noteHistoryGridView.MasterGridViewTemplate.EnableGrouping = false;
            this.noteHistoryGridView.MasterGridViewTemplate.ShowRowHeaderColumn = false;
            gridSortField1.FieldAlias = "columnDate";
            gridSortField1.FieldName = "columnDate";
            this.noteHistoryGridView.MasterGridViewTemplate.SortExpressions.Add(gridSortField1);
            this.noteHistoryGridView.Name = "noteHistoryGridView";
            this.noteHistoryGridView.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.noteHistoryGridView.SelectionMode = Telerik.WinControls.UI.GridViewSelectionMode.CellSelect;
            this.noteHistoryGridView.ShowGroupPanel = false;
            this.noteHistoryGridView.Size = new System.Drawing.Size(400, 122);
            this.noteHistoryGridView.TabIndex = 1;
            this.noteHistoryGridView.ThemeName = "ControlDefault";
            this.noteHistoryGridView.CellValueChanged += new Telerik.WinControls.UI.GridViewCellEventHandler(this.noteHistoryGridView_CellValueChanged);
            //
            // NoteHistoryControl
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.noteHistoryGridView);
            this.Controls.Add(this.panel1);
            this.MinimumSize = new System.Drawing.Size(350, 125);
            this.Name = "NoteHistoryControl";
            this.Size = new System.Drawing.Size(400, 150);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.noteHistoryGridView.MasterGridViewTemplate)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.noteHistoryGridView)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
 
        }

Felipe
Top achievements
Rank 1
 answered on 26 Jun 2013
1 answer
117 views
When you have a radgrid using UseStaticHeaders=True, the radgrid's width fills the browser.  If you resize the columns using best fit, sometimes, depending on how many columns you have, an empty column shows up filling the space between your last column and the radgrids right boundary.  How is this done?  I am trying to achieve the same effect using columns with HeaderWidths specified.  Do I just add an empty GridTemplateColumn?
Angel Petrov
Telerik team
 answered on 26 Jun 2013
2 answers
255 views
Hi,

To reproduce problem just add 3 columns to grid and paste code below to Load event.

private void Form1_Load(object sender, EventArgs e)
{
    DataTable dt = new DataTable();
    dt.Columns.Add("d1", typeof(Decimal));
    dt.Columns.Add("d2", typeof(Decimal));
 
    dt.Rows.Add(new object[] { 3, 4 });
    dt.Rows.Add(new object[] { 1, 4 });
    dt.Rows.Add(new object[] { 0, 3 });
    dt.Rows.Add(new object[] { 3, 3 });
 
    radGridView1.Columns[0].FieldName = "d1";
    radGridView1.Columns[0].HeaderText = "d1";
    radGridView1.Columns[0].Name = "d1";
 
    radGridView1.Columns[1].FieldName = "d2";
    radGridView1.Columns[1].HeaderText = "d2";
    radGridView1.Columns[1].Name = "d2";
 
    radGridView1.Columns[2].HeaderText = "exp";
 
    radGridView1.DataSource = dt;
 
    radGridView1.Columns[2].Expression = "IIF(d1 = 0, 0, d2 / d1 )";
}

Even if we apply the condition that checks divide by zero, program will trow error:
A first chance exception of type 'System.DivideByZeroException' occurred in mscorlib.dll 

I was able to fool the "Expression" by double condition like this:

radGridView1.Columns[2].Expression = "IIF(d1 = 0, 0, d2 / (IIF(d1 = 0, 9999 , d1)))";




Dimitar
Telerik team
 answered on 25 Jun 2013
2 answers
189 views
I want to disable treenode auto-expansion for certain nodes when I drag a treenode .  I tried the DragOverEvent but it did not do what I wanted.  I know the Animation property was not correct, but couldn't find anything else.

Private Sub tvwSetup_DragOverNode(sender As Object, e As RadTreeViewDragCancelEventArgs) Handles tvwSetup.DragOverNode
 
     'disable expansion for nodes with values < 100
     If e.TargetNode.Value < 100 Then tvwSetup.ExpandAnimation = ExpandAnimation.None
End Sub

I've seen a solution for ASP using the "OnClientNodeExpanding" event.  Can such a thing be done in the Winforms treeview?
Brendan
Top achievements
Rank 1
 answered on 25 Jun 2013
0 answers
121 views
While reordering the rows in rad grid the scroll bar is not moving

Example : - 

i'm having 37 rows and scrolling is also shown and 

now see the pic 1 : i'm selecting one row and moving it down

now see the pic 2 : you can see the selected row is visible up to the height of the grid view

now see the pic 3 : if you still move the selected row down, its moving down but the scroll bar is not moving parallel and the selected row is not visible to the user
Manesh
Top achievements
Rank 2
 asked on 25 Jun 2013
9 answers
430 views
Hi,
    I want to reorder the rows within a grid with few condition. For example, i have 10 records in the grid.
The first 2 records should not reordered.
From the 3rd to 10th record, they can be re ordered between themselves and not with record 1 and 2. How should i acheive this?
Is there any event to handle the Reorder event?
Manesh
Top achievements
Rank 2
 answered on 25 Jun 2013
2 answers
258 views
Hi, I have a problem and can't find a solution for it:
I have this code that should add a new page to the ...UI.Docking.DocumentWindow on Form1. If I use it on a button on Form1 works fine, but if I try to call it from Form2 the code runs through and show's the messageBox on the end but it doesn't add the page, here's the code:

private void mNextP1_Click(object sender, EventArgs e)
{
    string txt = File.ReadAllText("c:\\1.html");
    string style = File.ReadAllText("c:\\styles.css");
 
    Form f = new Form();
    f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    f.Dock = DockStyle.Fill;
    WebBrowser wb = new WebBrowser();
    wb.DocumentText = "";
    wb.Dock = DockStyle.Fill;
    doc = wb.Document.DomDocument as IHTMLDocument2;
    doc.designMode = "On";
    doc.write(txt);
    IHTMLStyleSheet styleSheet = doc.createStyleSheet("", 0);
    styleSheet.cssText = style;
 
    f.Controls.Add(wb);
 
    DocumentWindow dw = new DocumentWindow();
    f.TopLevel = false;
 
    dw.Controls.Add(f);
    f.Show();
    dw.Text = "Contents";
    radDock1.AddDocument(dw);
    radDock1.ActiveWindow = dw;
 
    MessageBox.Show("Done");
}
This one works just fine, but here comes the problem:
I have this on my form2:
Form1 form1 = new Form1();
form1.newBlankProject();

and the code for "form1.newBlankProject();" is the same as above, but for some reason it only show's the messagebox with the text "Done2" and nothing else happens. Here's the code for that one too:

public void newBlankProject()
{
    string txt = File.ReadAllText("c:\\1.html");
    string style = File.ReadAllText("c:\\styles.css");
 
    Form f = new Form();
    f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    f.Dock = DockStyle.Fill;
    WebBrowser wb = new WebBrowser();
    wb.DocumentText = "";
    wb.Dock = DockStyle.Fill;
    doc = wb.Document.DomDocument as IHTMLDocument2;
    doc.designMode = "On";
    doc.write(txt);
    IHTMLStyleSheet styleSheet = doc.createStyleSheet("", 0);
    styleSheet.cssText = style;
 
    f.Controls.Add(wb);
 
    DocumentWindow dw = new DocumentWindow();
    f.TopLevel = false;
 
    dw.Controls.Add(f);
    f.Show();
    dw.Text = "Contents";
    radDock1.AddDocument(dw);
    radDock1.ActiveWindow = dw;
 
    MessageBox.Show("Done2");
}

Probably is just a stupid mistake on my part, but I can't figure out what the problem may be, any help or ideas are appreciated,

Thanks,
Z


Szabolcs
Top achievements
Rank 1
 answered on 25 Jun 2013
3 answers
204 views
I have juste installed the new version of RadControl for Winform and I have notice a little issue with the VisualStudio 2010 add-in.

There is no more menu for adding a RadForm to a Project, upgrading a Project to the new version of assembly, etc. In fact, there is only a "About" item in the menu.

It's not painfull to update the references by hand but theses Tools where nice to have !


Missing User
 answered on 25 Jun 2013
3 answers
266 views

I am trying to use the combo in virtual mode, but am getting poor performance.  If I arrow down while focus is in the text box, it responds OK, but if I click the drop down button it takes quite a while to respond.   

Sample code follows.  Any ideas?

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
 
        radMultiColumnComboBox1.EditorControl.EnableSorting = false;
        radMultiColumnComboBox1.EditorControl.EnableFiltering  = false;
        radMultiColumnComboBox1.EditorControl.EnableGrouping = false;
 
    }
 
 
    private void Form1_Load(object sender, EventArgs e)
    {
 
        radMultiColumnComboBox1.EditorControl.VirtualMode = true;
        radMultiColumnComboBox1.EditorControl.CellValueNeeded += new Telerik.WinControls.UI.GridViewCellValueEventHandler(EditorControl_CellValueNeeded);
        radMultiColumnComboBox1.EditorControl.ColumnCount = 2;
        radMultiColumnComboBox1.EditorControl.RowCount = 2000;
 
 
 
    }
 
    void EditorControl_CellValueNeeded(object sender, Telerik.WinControls.UI.GridViewCellValueEventArgs e)
    {
        e.Value = e.RowIndex.ToString() + "," + e.ColumnIndex.ToString();
    }
}
Peter
Telerik team
 answered on 25 Jun 2013
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
PdfViewer and PdfViewerNavigator
CommandBar
ListControl
Carousel
GanttView
Diagram, DiagramRibbonBar, DiagramToolBox
Panorama
New Product Suggestions
VirtualGrid
Toolstrip (obsolete as of Q3 2010)
Label
AutoCompleteBox
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
SplitContainer
Documentation
Map
DesktopAlert
CheckedDropDownList
ProgressBar
MessageBox
TrackBar
Rotator
SpinEditor
CheckedListBox
StatusStrip
Wizard
CollapsiblePanel
LayoutControl
ShapedForm
SyntaxEditor
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
SmartPasteButton
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?