Telerik Forums
UI for WinForms Forum
1 answer
936 views


Hi,

I'm having some problems with the RadGridView's DataBindingComplete event handler in a async context and with the Telerik's WinForm RadGridView BestFitColumns method.

I'm developing an winforms with Telerik application that loads data from several db tables and shows them in distinct RadGridViews (one for each table source).
Each of the grids is inside a DocumentWindow. Each DocumentWindow is inside DocumentContainer and all of the DocumentContainers are under a single aggregating Docking.DocumentTabStrip.

The process db table information process is asyncronous so that the UI is free allowing the user to see the information in one table when it becomes available even if one of the other tables are still being loaded.

The first problem is that the DataBindingComplete is only triggered when the user selects the respective tab. Since some of the DataBindingComplete logic can be quite time consuming it leads to a undesired user experience until the data is finally presented.
Is there an alternative event that can be triggered when the data is already available in the RadGridView but without the need of having the user triggering it?

The second is with the way the BestFitColumns method determines the column width. The native DataGridView column's AutoSizeMode contains a option of AllDataCellsExceptHeader that I'm unable to emulate in Telerik.
The documentation for these options is rather scarce and all of the tried options fall short.
Of the available options the closest are the AllCells, DisplayedCells and DisplayedDataCells as the others do not take in account the cell's values.
The AllCells and DisplayedCells use the column headers as input and that makes data spread out too much, which is undesired.
The closest is DisplayedDataCells that sort of works but the logic seems to only use the cells in the rows in the visible range. (I.E.: the rows presented when the grid is presented in the UI). Trying to explain better, if form only displays the first Nth data rows, after the method runs the data will be visible correctly formatted, but if the (N+1) row data has a width larger than any of the first Nth rows the displayed data will be truncated and suffixed with the "..". Is there a way to emulate the AllDataCellsExceptHeader at all?

Thanks for your help.

Regards,

I've implement it using the following logic (snipped code).

(..)
  private async void displayButton_Click (object sender, EventArgs e) {
  (..)
    await Task.Run(() => Parallel.ForEach(tablesToRetrieve.Keys, tableID => {
      (..)
      DocumentWindow docWindow = ((DocumentWindow)returnedDataDocumentTabStrip.Controls[tableName]);
       
      if (GetDBTableData(tableID, tableArguments, out dataTable)) {
        docWindow.Invoke((Action)delegate {
          docWindow.Controls.Add(newRadView(dataTable));
          docWindow.Refresh();
        });
      }
      (..)
    }));
  }
  (..)
  private RadGridView newRadView(DataTable dTable) {
  
    RadGridView gridView = new RadGridView();   
    gridView.AutoSizeRows = false;
    gridView.AllowAutoSizeColumns = true;
    gridView.ReadOnly = true;
    gridView.AutoExpandGroups = true;
    gridView.AllowAddNewRow = false;
    gridView.AllowDeleteRow = false;
    gridView.AllowColumnReorder = true;
    gridView.AllowColumnResize = true;
    gridView.MultiSelect = true;
    gridView.SelectionMode= GridViewSelectionMode.CellSelect;       
    gridView.EnableFiltering = true;
    gridView.MasterTemplate.EnableFiltering = true;       
    gridView.ShowHeaderCellButtons = true;
    gridView.EnableAlternatingRowColor = true;
    gridView.EnableGrouping = true;
    gridView.MasterTemplate.EnableGrouping  =true;
    gridView.EnableSorting = true;
    gridView.MasterTemplate.EnableSorting = true;       
    gridView.TableElement.AlternatingRowColor = Color.FromArgb(240, 240, 240);
    gridView.TableElement.RowHeight = 18;
    gridView.ShowFilteringRow = true;
    gridView.Dock = DockStyle.Fill;       
    gridView.AllowSearchRow = true;       
    gridView.SearchRowPosition = SystemRowPosition.Bottom;
    gridView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;   
    gridView.Name = dTable.TableName;
     
    /* Arm events handlers   
    gridView.ViewCellFormatting += gridView_ViewCellFormatting;
    gridView.DataBindingComplete += gridView_DataBindingComplete;
    gridView.ToolTipTextNeeded += gridView_ToolTipTextNeeded;
 
    /* Load dataTable data */
    gridView.BeginUpdate();
    gridView.DataSource = new BindingSource(dataTable, null);
     
    /* Customize table sort assumptions */   
    gridView.SortDescriptors.Add(new SortDescriptor("DUMMY_COLUMN", System.ComponentModel.ListSortDirection.Descending));
     
    gridView.EndUpdate(true);
     
    return gridView; 
  }
  (..)
  private void gridView_ViewCellFormatting(object sender, CellFormattingEventArgs e) {
    if (e.CellElement.GetType() == typeof(GridHeaderCellElement))
      e.CellElement.TextWrap = true;
  }
  (..)
  private void gridView_DataBindingComplete(object sender, GridViewBindingCompleteEventArgs e) {
    RadGridView gridView = (RadGridView)sender;
     
    /* Show/Shift/Hide columns to display */
    (..)
     
    /* Finally Adjust columns to it's data */
    gridView.BestFitColumns(BestFitColumnMode.DisplayedDataCells);
  }

Hristo
Telerik team
 answered on 22 Jun 2016
1 answer
38 views

Hi,

 

I was wondering how I would go about modifying the radCalender control so that the currentTimePointer is drawn only on the current week rather than on every week in the calendar.

 

I already have a customDayViewApppointmentsTable class that derives from the DayViewAppointmentsTable class that I've used to modify the size of the currentTimePointer, would the desired functionality be accessed through another override in this class?

 

Thanks,

Robert

Hristo
Telerik team
 answered on 21 Jun 2016
3 answers
139 views

I need a ComboBox column initialized with some data and the user can enter new data too when inserting new row into grid. For example, ComboBox column has three items by default Phone, Mobile, Fax, but the user needs to insert new item (e.g., Code). How can I do this?

Here is the code. With this code the user can only select one of the default values of combo column and he/she cannot enter his/her new value into combo column.

DataTable table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Value", typeof(string));
var details = db.BatchItemDetails.Where(d => d.BatchItem_Id == _id)
                       .Select(d => new { d.Name, d.Value });
foreach (var row in details)
   table.Rows.Add(row.Name, row.Value);
 
grid.MasterTemplate.AutoGenerateColumns = false;
grid.DataSource = table;
 
GridViewComboBoxColumn name = new GridViewComboBoxColumn();
name.DataSource = (from b in db.Batches
             join i in db.BatchItems on b.Id equals i.Batch_Id
             join d in db.BatchItemDetails on i.Id equals d.BatchItem_Id
             where b.Id == batchId
             orderby d.Name
             select d.Name).Distinct().ToArray(); // string array.
 
name.AutoCompleteMode = AutoCompleteMode.Suggest;
name.DropDownStyle = RadDropDownStyle.DropDown;
name.Name = "Name";
name.FieldName = "Name";
name.HeaderText = "عنوان اطلاعات";
name.Width = 219;
name.TextAlignment = ContentAlignment.MiddleLeft;
grid.Columns.Add(name);
 
grid.Columns.Add("Value", "شرح اطلاعات", "Value");
grid.Columns["Value"].Width = 353;
 
grid.AutoSizeRows = true;

Hristo
Telerik team
 answered on 21 Jun 2016
5 answers
134 views

Hello,

i created a custom cell element.

The custom part of the Element is a RadListControl.

The functionality works but I want the ListControl Element fit perfect in the Cell.

I have tried a lot and read many forum threads to find a solution but nothing works.

There are still Gaps (see Screenshot).

I hope someone can help me quick with my request.

Greets André

 

Dimitar
Telerik team
 answered on 21 Jun 2016
21 answers
303 views
Hi,

It seems that when setting both "Right to Left Layout" and "Right to Left" properties of the RadForm to 'True' the border of the form is drawn incorrectly, with the left side of the border disappearing.

Also, I am using the theme Office2007Blue.

Roy.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 21 Jun 2016
1 answer
73 views

Hi,

 

I am using the scheduler and I need to change the connection string at run time. How can I do that?

 

Thanks for the help.

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 21 Jun 2016
3 answers
222 views

Hi, i would like to know if when a user close a page on the pageview, the controls inside this page will be dereferenced (thus become eligible for garbage collection) or if I have to handle the closed event and manually remove all the controls inside the page.

Also would like to know if there is something I can do to cleanup removed pages or if the removed pages are automatically managed by the pageview control or if i have to call dispose on the page itself in the closed event.

It's just to be sure not to lock too much memory for too long time, i did not find a documentation page about this.

Best regards

Andrea

Dimitar
Telerik team
 answered on 21 Jun 2016
4 answers
213 views
When I edit a cell then move to another cell the editor is opened for the moved to cell. How do I change this behavior so the editor does not open when moving to a new cell?
Kyle
Top achievements
Rank 1
 answered on 20 Jun 2016
1 answer
219 views

if we are using simple combo box with let suppose database. below is the example of datasource

 

1.     Florida    = FL

2.    NewYork  = NY

3.    New Jerssy = NJ

if user press N (combo box is selected) it will select New York and if user again press N it will select next item in the list New Jerssy. can we have same behavior with multicolumn combo box. 

 

regards,

zeeshan

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 20 Jun 2016
5 answers
322 views

Dear,

is there any capability to change or set the column type dynamically to GridViewHyperlinkColumn after binding?

 

 

Regards,

Dimitar
Telerik team
 answered on 20 Jun 2016
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)
Chart (obsolete as of Q1 2013)
Form
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
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
CheckedDropDownList
ProgressBar
TrackBar
MessageBox
Rotator
SpinEditor
CheckedListBox
StatusStrip
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
CollapsiblePanel
Conversational UI, Chat
DateTimePicker
TabbedForm
CAB Enabling Kit
GroupBox
WaitingBar
DataEntry
ScrollablePanel
ScrollBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
Styling
Barcode
PopupEditor
RibbonForm
TaskBoard
Callout
ColorBox
PictureBox
FilterView
NavigationView
Accessibility
VirtualKeyboard
DataLayout
Licensing
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
AI Coding Assistant
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?