Telerik Forums
UI for WinForms Forum
0 answers
209 views
When I stop to select the node, is shaded. 

This time, I do the dragdrop from the ListView to Treeview. 

In return the default backcolor of treeview node.





RadTreeNode _previousNode = null;

    private void tvwExplorer_DragOver(object sender, DragEventArgs e)
    {
      if (this._previousNode != null)
      {
        this._previousNode.BackColor = SystemColors.HighlightText;
        this._previousNode.ForeColor = SystemColors.ControlText;
      }

      Point pt = ((RadTreeView)sender).PointToClient(new Point(e.X, e.Y));      
      RadTreeNode tn = this.tvwExplorer.GetNodeAt(pt);
      if (tn != null)
      {
        tn.BackColor = SystemColors.Highlight;
        tn.ForeColor = SystemColors.HighlightText;
      }
      this._previousNode = tn;
    }




Cesar
Top achievements
Rank 1
 asked on 21 Aug 2014
1 answer
252 views
I'm trying to make a gridview object dynamic so I don't have to update and distribute a binary every time I want to change the grid construction.

Background:
1) database table with information about reports called GeotechReports
2) database table with information about each field in GeotechReports called GeotechSetup
3) gridview object called GeotechGrid that has AutoGenerateColumns="True"
4) listbox object called GeotechHideColListbox that is bound to GeotechGrid to set the content and state of each listbox member

Information I need from a table, but can't seem to get into the grid or listbox:
1) The GeotechSetup table has two fields of interest: header and visibility. I want to somehow grab the header from this table for the grid to use so the database field name isn't the column header. Since the data is in GeotechReports and the header name is in GeotechSetup (different tables), I don't know how to make the grid understand to look at another datacontext/database table.
2) I want to change the listbox state in the same manner as above. By that I mean I want to set the state based on the visibility field in GeotechSetup.

Here's the relevant xaml:

<telerik:RadGridView Grid.Row="1" Grid.Column="0"
            HorizontalAlignment="Stretch" Margin="0,0,0,0"
            CanUserDeleteRows="False"     CanUserInsertRows="False"
            IsReadOnly="True"             IsFilteringAllowed="True"
            ColumnWidth="*"               SelectionMode="Multiple"
            SelectionUnit="FullRow"       AutoGenerateColumns="True"
            GroupRenderMode="Flat"        AutoExpandGroups="True"
            IsSynchronizedWithCurrentItem="True" x:Name="GeotechGrid"
            ItemsSource="{Binding Path=ReportsToDisplay, Mode=OneWay}"
            SelectedItem="{Binding Path=SelectedReport, Mode=TwoWay}">
 
    <telerik:RadGridView.Columns/>
</telerik:RadGridView>


<ListBox ItemsSource="{Binding Columns, ElementName=GeotechGrid}"
      x:Name="GeotechHideColListbox">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <CheckBox Content="{Binding Header}"
                  IsChecked="{Binding IsVisible, Mode=TwoWay}" />
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Essentially what I'm asking is how do I programmatically get access to GeotechGrid and then update each column with the header information stored in GeotechSetup? Here's what I've got so far. I know it accesses the GeotechSetups context as expected from the rlinq object because I displayed x.Fieldname and x.Fieldheader to a message box.

private void RetrieveSetupParameters()
{
  foreach(GeotechSetup x in this.context.GeotechSetups.ToList())
  {
    // 1) x.Fieldname is the name of the field in the GeotechReport table
    // 2) x.FieldHeader is what I want to be the column header text
    // 3) x.FieldVisibility is what I want to use to set the listbox items
    //    and hide the columns I specify in the database
  }
}

I don't need the communication to be in twoway mode. I'm only interested in doing this to set column default states on first load.
Dimitrina
Telerik team
 answered on 21 Aug 2014
1 answer
1.0K+ views
Hi,

I've added GridViewImageColumn and am displaying the image from local path using
Bitmap.FromFile(this.Value.ToString()); as was specified in one of your links.That is working fine.

The issue here is that the images can be of varying sizes, hence the row height is not uniform. We need to either generate thumbnails for these images and then display in the column,
Is there any way to specify the height and width for the Image so that it would resize accordingly without getting truncated.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 21 Aug 2014
1 answer
239 views
I'm creating a PDF file using the PdfStamper in iTextSharp and return the PDF as a memorystream object to the calling function, that is then used to display the PDF in Teleriks PDF Viewer Component for WinForms. That's the objective.Right now, creating the PDF works as it should, and it returns the data to the Calling function, and in the Calling function, should I write the memorystream contents to a file stream and then open it in Adobe Reader Everything looks just fine.However, if I choose to display the PDF in the PDF Viewer Control I just get an "Unsupported Stream type" error.Now, I figured something was wrong in the PDF data so I decided to create the PDF file, save it to disk, then read it to a memorystream in the Calling function and display that memorystream in the PDF Viewer and that, for some to me unknown reason, works.... I really can't get my head around this and need some help.

So, this won't work:

//The Calling function
    private void dlgViewPDF_Load(object sender, EventArgs e)
{
    MemoryStream ms = PDFcreator.GeneratePDFdata(id);
 
   rPdfView.LoadDocument(ms);
}
 
//The PDF generator
public static MemoryStream GeneratePDFdata(string id)
{
            MemoryStream ms = new MemoryStream();
 
            string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf");
 
            PdfReader pdfReader = new PdfReader(sTemplate);
            PdfStamper pdfStamper = new PdfStamper(pdfReader, ms);
 
            PdfContentByte cb = pdfStamper.GetOverContent(1);
 
            BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
            BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED);
            cb.SetColorFill(iTextSharp.text.Color.BLACK);
            cb.SetFontAndSize(baseFontBold, 14);
 
            cb.BeginText();
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST!!", 385, 750, 0);
            cb.EndText();
 
            cb.SetColorStroke(new CMYKColor(0f, 0f, 0f, 1f));
            cb.SetColorFill(new CMYKColor(0f, 0f, 0f, 1f));
 
            cb.MoveTo(139, 398);
            cb.LineTo(146, 398);
            cb.LineTo(146, 391);
            cb.LineTo(139, 391);
            cb.ClosePathEoFillStroke();
 
            pdfStamper.Close();
            pdfReader.Close();
 
            return ms;
}

But this WILL work:
//The Calling function
private void dlgViewPDF_Load(object sender, EventArgs e)
{
    MemoryStream ms = new MemoryStream();
 
    FileStream file = new FileStream(@"c:\temp\testfile.pdf", FileMode.Open, FileAccess.Read);
 
    byte[] bytes = new byte[file.Length];
    file.Read(bytes, 0, (int)file.Length);
    ms.Write(bytes, 0, (int)file.Length);
 
    rPdfView.LoadDocument(ms);
}
 
 
//The PDF generator
public static void GeneratePDFdata(string id)
{
            MemoryStream ms = new MemoryStream();
 
            string sTemplate = string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\template.pdf");
 
            PdfReader pdfReader = new PdfReader(sTemplate);
 
            FileStream fs = new FileStream(@"c:\temp\testfile.pdf", FileMode.Create, FileAccess.Write, FileShare.None);
            PdfStamper pdfStamper = new PdfStamper(pdfReader, fs);
 
            PdfContentByte cb = pdfStamper.GetOverContent(1);
 
            BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED);
            BaseFont baseFontBold = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.EMBEDDED);
            cb.SetColorFill(iTextSharp.text.Color.BLACK);
            cb.SetFontAndSize(baseFontBold, 14);
 
            cb.BeginText();
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "TEST!!", 385, 750, 0);
            cb.EndText();
 
            cb.SetColorStroke(new CMYKColor(0f, 0f, 0f, 1f));
            cb.SetColorFill(new CMYKColor(0f, 0f, 0f, 1f));
 
            cb.MoveTo(139, 398);
            cb.LineTo(146, 398);
            cb.LineTo(146, 391);
            cb.LineTo(139, 391);
            cb.ClosePathEoFillStroke();
 
            pdfStamper.Close();
            pdfReader.Close();
}

But why? I'd rather keep it all in memory and let the user save the resulting PDF if he/she so wishes than having to write it to disk and then displaying it.
Am I missing some crucial step here?


Johannes
Top achievements
Rank 1
 answered on 21 Aug 2014
2 answers
170 views
Hi,

I have a stacked100 bar chart.  It "seems" to be structured the way I want it structured, it's just the colors aren't contrasting.

I did a mouseover on the "Jan 2014" so you can see it is indeed breaking it into the percentages properly (see attached).

How do I get the colors to contrast or did I simply structure the code incorrectly? (admittedly series and categories confuse me at times)

Thanks for your help.

Code:
            DataTable dt = new DataTable();
            dt = f.CallStoredProcedure("rptHitRate_Chart");
            
            BarSeries b1 = new Telerik.WinControls.UI.BarSeries();
            BarSeries b2 = new Telerik.WinControls.UI.BarSeries();

            b1.CombineMode = ChartSeriesCombineMode.Stack100;
            //b2.CombineMode = ChartSeriesCombineMode.Stack100;        

            chartHitRate_Monthly.Series.Add(b1);

            foreach (DataRow dr in dt.Rows)
            {
                CategoricalDataPoint cdp = new CategoricalDataPoint((double)dr["ApprovalRate"], dr["DateGroup"]);
                CategoricalDataPoint cdp2 = new CategoricalDataPoint((double)dr["DeclineRate"], dr["DateGroup"]);

                b1.DataPoints.Add(cdp);
                b1.DataPoints.Add(cdp2);
            }  

data layout:
DateGroup  ApprovalRate DeclineRate
Jan 2014 0.368421052631579 0.631578947368421
Feb 2014 0.75 0.25
Mar 2014 0.568965517241379 0.431034482758621
Apr 2014  0.423728813559322 0.576271186440678
May 2014 0.392857142857143 0.607142857142857
Jun 2014 0.457627118644068 0.542372881355932
Jul 2014 0.433962264150943 0.566037735849057
Aug 2014 0.315789473684211 0.684210526315789

Stefan
Telerik team
 answered on 21 Aug 2014
4 answers
155 views
I know this may seem like a ridiculous question, I may be missing something, but can someone explain to me what the point of the "Download..." and "Browse..." buttons are in the Solution Upgrade Wizard?

There's two things I can think of:

    a) the browse button is meant for me to select a new location then click the download button to download the new version, or
    b) the browse button is for me to select a folder where the assemblies currently exist and upgrade them with the download button

Here's why (in it's current form) it doesn't make sense or is just very unintuitive:

In both cases, the flow of the form is really strange.  Typically entry fields would go from top-down, left-right - or - left-right, top-down.  This upgrade form goes right-to-left.

That's not the real issue (but for a company who provides controls for helping with UX, you would think UX would be important in their own forms ;-) ... ).

I assumed I could click Browse, create a folder (why else would there be a "New Folder" option in the Folder Browse dialog?), and then download the assemblies to that location.  Is that assumption correct?

If that assumption is correct, then I think there's a bug or something, because I created a new folder, clicked the download button (which tells me it was already up to date), and my folder is empty.  See attached screenshots ...

Thank you
Dyanko
Telerik team
 answered on 20 Aug 2014
1 answer
118 views
When I import text into my rich text control (2014.2.715), the custom dictionary is lost.

I'm using the following code:
var provider = new RtfFormatProvider();
rtf.Document = provider.Import(value);

I'm using the following to set my custom dictionary:
var culture = CultureInfo.GetCultureInfo("en-AU");
var checker = (DocumentSpellChecker)rtf.SpellChecker;
if (!(checker.GetDictionary(culture) is AustralianDictionary))
{
checker.AddDictionary(new AustralianDictionary(), culture);
}
rtf.SpellChecker.SpellCheckingCulture = culture;

Am I doing something wrong?  What is the correct way to set a custom dictionary?


Dimitar
Telerik team
 answered on 20 Aug 2014
1 answer
203 views
Hello Again...

I want to be able to hide a Group in the Group By.

I am binding the grid to a custom business object.  For example:

​class PermissionBinding
{
     public string PermissionName { get; set; }
     public string PermissionGroup { get; set; }
}

And the data in a BindingList<PermissionBinding> (#id, Permission Name, Permission Group) has:
#0:    Create, Group 1
#1:    Edit, Group 1
#2:    View, Group 1
#3:    Delete, Group 1
​#4:    Create, Group 2
#5:    Edit, Group 2
#6:    View, Group 2
#7:    Delete, Group 2

... and so on.

So I bind the list to the grid via a BindingSource (all set up via the designer).  But I create my list and set it to the binding source using:

_permissions = CreatePermissionBinding();
this.permissionBindingBindingSource.DataSource = _permissions;

I use Custom Grouping to group the rows under each Permission group nicely using the following:

Field Members (used to order the Groups and format the group name)
private const string GroupSortFormat = "{0:D4}. {1}|{1}";
        private Dictionary<string, int> _groupOrder = new Dictionary<string, int>()
        {
            { "Group 1", 1 },
            { "Group 2", 2 },
            { "Group 3", 3 },
       };

Form Constructor
this.PermissionGridView.CustomGrouping += PermissionGridView_CustomGrouping;
this.PermissionGridView.GroupSummaryEvaluate += PermissionGridView_GroupSummaryEvaluate;
this.PermissionGridView.EnableCustomGrouping = true;            
this.PermissionGridView.GroupDescriptors.Add(new Telerik.WinControls.Data.GroupDescriptor("PermissionGroup"));

Event Handlers

        private void PermissionGridView_GroupSummaryEvaluate(object sender, Telerik.WinControls.UI.GroupSummaryEvaluationEventArgs e)
        {
            if (e.Value == null)
            {
                e.FormatString = e.Group.Key.ToString().Split('|')[1]; // strip out the order from the format string to show the group name
            }
        }
        
        private void PermissionGridView_CustomGrouping(object sender, Telerik.WinControls.UI.GridViewCustomGroupingEventArgs e)
        {
            var obj = (PermissionBinding)e.Row.DataBoundItem;
            e.GroupKey = string.Format(GroupSortFormat, _groupOrder[obj.PermissionGroup], obj.PermissionGroup); // make sure group is ordrered via string format
        }

Now suppose I want to hide Group 2.  Can I do it?

I have tried the following which only hides the rows in a group - it still shows the grouping Group 2:
foreach (var row in this.PermissionGridView.Rows)
{
        row.IsVisible = groups.Contains((row.DataBoundItem as PermissionBinding).PermissionGroup) ? true : false;


I have successfully done it by removing the groups from the binding source BindingList<PermissionBinding>.  But I see this as a view/filter on the data - suppose this is triggered by a user clicking a button.  I really don't want to create the data source each time as it is populated through the database.  Although it is not a major issue.  I could maintain 2 lists - one main list and one filtered.  But I was wondering if there was something in the Grid I had obviously missed to do this.

NOTE:  Telerik is seriously kicking a competitors product into touch the more I do with it ;)!

Thanks,

Andez
Dimitar
Telerik team
 answered on 20 Aug 2014
2 answers
154 views
Hi,

I have the following

provider.ColumnGroupDescriptions.Add(new PropertyGroupDescription() { PropertyName = "DispatchDate", GroupComparer = new GroupNameComparer() });
provider.ColumnGroupDescriptions[0].SortOrder = Telerik.Pivot.Core.SortOrder.Ascending;

DispatchDate is a Datetime field.

So far so good.

But can I format the date field to read MM YY (May 14) in the column header?

I tried to change the DispatchDate to a string, but that messes up the sort, so if I could format the date field that would be great.

Thanks
Shaun.





Shaun
Top achievements
Rank 1
 answered on 19 Aug 2014
1 answer
103 views
Hi,

When creating a new solution with an empty RadForm, the initial memory usage is around 30-40MB.
Is there anyway to reduce this memory usage?

Thanks in advance.

~ Erez
Dimitar
Telerik team
 answered on 19 Aug 2014
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?