Telerik Forums
UI for WPF Forum
5 answers
278 views
Hi,

I am using the last internal build.

I am setting up a combo box using the following xaml:

<telerik:GridViewDataColumn DataMemberBinding="{Binding TrueType.Name}"
    <telerik:GridViewDataColumn.CellEditTemplate> 
        <DataTemplate> 
            <ComboBox SelectedItem="{Binding TrueType}" DisplayMemberPath="Name" ItemsSource="{Binding TrueTypeValues}"/>    
        </DataTemplate> 
    </telerik:GridViewDataColumn.CellEditTemplate> 
</telerik:GridViewDataColumn> 
 

What happens after that is quiet random.  On some computer, the combobox will work fine for a couple of tries.  And on some computer, the combobox simply refuse to open.  We click on it and nothing happens.  We can notice a tiny window that flash for .1 second on the top left corner of the screen when that happens the first time.
Yoan
Telerik team
 answered on 03 Oct 2014
9 answers
676 views
Hello,
How is the IsComboBoxEditable property works? I need to present a grid where one column is a combobox. The user can select one value from the list or enter a new value so I set the IsComboBoxEditable to true but the problem is that if the user types a value that is not in the ItemsSource the Text is blank when the combobox looses the focus. Can you please tell me what I'm doing wrong?

 

 

<Telerik:GridViewComboBoxColumn Header="Location" Width="110" IsComboBoxEditable="True"

 

 

SelectedValueMemberPath="Name"

 

 

DisplayMemberPath="Name"

 

 

DataMemberBinding="{Binding [Location]}"/>

 


In code I bind the Itemsource to the available list.

((

GridViewComboBoxColumn)tblTrain.Columns[2]).ItemsSource = GetTrainToFacilities();

 

Yoan
Telerik team
 answered on 03 Oct 2014
15 answers
1.3K+ views
How can I programmatically create, using C# and RadDocument, a Microsoft Word document with a cover page, table of contents, then body with several sections and subsections?

- It is a simple document assembly operation
- It is for a desktop WPF application, C#, .NET 4.5
- The document is relatively short with less than 10 top level sections and less than 25 subsections
- The number of sections is variable depending on the data entered in the rest of the desktop application
- The document created should be in MS Word 2010 format if possible.
- The document is created without a Telerik RichTextEdit control visible.  Currently, there is no Telerik RichTextEdit control used in the application.I've attached a sample Word 2010 document.

Attached are the pages from the sample Word document with dummy data.


The attached short 3 page Word document with dummy data gives the basic layout.
C
Top achievements
Rank 1
 answered on 01 Oct 2014
2 answers
172 views
Hi there,

Version: 2013.2.611.45

I have a word document that i am importing and working with. It's a form that has a 3 of 9 barcode string vertically in the left margin. When I import the document and show it in the editor, the barcode is no longer top to bottom direction but left to right,.

I read around this forum and stackoverflow and I gathered that text direction is not supported at this point in time. Has this changed at all since our version?

I also tried the suggestion of using a WPF label rotated and put inside a UIInlineContainer and inserted into the editor, which works fine, but as i came across in the documentation these are not saved when output to docx, which i must do.

Do i have any options whatsoever to at least simulate rotated text?

Many thanks for your time,
J
C
Top achievements
Rank 1
 answered on 01 Oct 2014
2 answers
644 views
How do you change the font size, color, weight, etc. when writing a Microsoft Word document using RadDocumentEditor?

The Word document created has all font in Calibri 6 point normal weight black in Microsoft Word 2010..
It should have different sizes/weights/colors of Calibri and Arial text.

{
RadDocument doc = new RadDocument();
RadDocumentEditor ed = new RadDocumentEditor(doc);

doc.SectionDefaultPageSize = PaperTypeConverter.ToSize(PaperTypes.Letter);
doc.SectionDefaultPageOrientation = PageOrientation.Portrait;
doc.SectionDefaultPageMargin = new Padding(50);

FontFamily fontCalibri = new FontFamily("Calibri");
FontFamily fontArial = new FontFamily("Arial");


ed.ChangeFontFamily(fontCalibri);
ed.ChangeFontSize(8.0);
ed.Insert("Test inserted Calibri");
ed.InsertLineBreak();

ed.ChangeFontFamily(fontArial);
ed.ChangeFontSize(12.0);
ed.Insert("Test inserted Arial");
ed.InsertLineBreak();

ed.ChangeFontFamily(fontCalibri);
ed.ChangeFontSize(15.0);
ed.ChangeFontWeight(FontWeights.Bold);
ed.Insert("Test inserted Calibri 2 bold");
ed.InsertLineBreak();

ed.ChangeFontFamily(fontCalibri);
ed.ChangeFontSize(30.0);
ed.ChangeForeColor(Color.FromRgb(255, 0, 0));
ed.ChangeFontStyle(FontStyles.Italic);
ed.ChangeFontWeight(FontWeights.Bold);
ed.Insert("Test inserted Calibri 2 bold itallic");
ed.InsertLineBreak();

doc.MeasureAndArrangeInDefaultSize();
ExportToWordDocx(doc, "test_report_doc_1.docx");
}

We are using C#, .net 4.5 and Telerik version 2014.2.617.45 of Telerik.Windows.Documents, Documents.Core and Documents.FormatProviders.OpenXmkl


C
Top achievements
Rank 1
 answered on 01 Oct 2014
2 answers
443 views
How should the TableWidthUnitType.Percent be used?  The TableWidthUnitType.Percent seems to be ignored in the following simple example.
Is there some other setting that needs to be done for the table to take up 100% of the page width excluding margins?

The tables are in the header and footer and need to take up 100% of the page width on each page without regard to page orientation.

internal class Test1
{
internal static void GenerateDocumentTest1()     //this is the main method
{
RadDocument document = new RadDocument();
document.LayoutMode = DocumentLayoutMode.Paged;  

//NOTE: Sizes used by Telerix RadDocument are in Device Independent Pixels (DIP) which are 96 to the inch
//  An 8.5 inch by 11 inch paper size is (8.5 * 96) DIP wide by (11 * 96) DIP tall
//  Use the Unit.InchToDip() conversion method to convert from inches to DIP.  The Unit class does other measurement conversions

document.SectionDefaultPageSize = PaperTypeConverter.ToSize(PaperTypes.Letter);
document.SectionDefaultPageOrientation = PageOrientation.Portrait;
const double pageSizeWidthInches = 8.5;
const double pageMarginSizeInches = 0.5; //page margin on all four sides of the page

const double pageContentWidthSizeInInches = pageSizeWidthInches - (2.0*pageMarginSizeInches); //printable area width of page - used for setting table widths in header and footer
int marginSizeDip = (int) Unit.InchToDip(pageMarginSizeInches); //Note: 96 DIP to the inch
document.SectionDefaultPageMargin = new Padding(marginSizeDip); // 50/100 of an inch for all margins

//------------------------------------------------------------
//build page headers to be applied to document
Header pageHeader = CreatePageHeader();
Footer pageFooter = CreatePageFooter();
{
Section sec = new Section() { PageOrientation = PageOrientation.Portrait};
Paragraph par = new Paragraph();
par.Inlines.Add(new Span("First Page Text A"));
sec.Blocks.Add(par);
sec.Headers.Default = pageHeader;
sec.Footers.Default = pageFooter;
document.Sections.Add(sec);
}

//---------------------------------------------------------
{
Section sec = new Section() { PageOrientation = PageOrientation.Landscape };
Paragraph par = new Paragraph();
par.Inlines.Add(new Span("Second Page Text B"));
par.Inlines.Add(new Span(DocumentEnvironment.NewLine));
sec.Blocks.Add(par);
sec.Headers.Default = pageHeader;
sec.Footers.Default = pageFooter;
document.Sections.Add(sec);
}

//---------------------------------------------------------
{
Section sec = new Section() { PageOrientation = PageOrientation.Portrait };
Paragraph par = new Paragraph();
par.Inlines.Add(new Span("Second Page Text B"));
par.Inlines.Add(new Span(DocumentEnvironment.NewLine));
sec.Blocks.Add(par);
sec.Headers.Default = pageHeader;
sec.Footers.Default = pageFooter;
document.Sections.Add(sec);
}

//---------------------------------------------------------------------
document.EnsureDocumentMeasuredAndArranged();
ExportToWordDocx(document, "test_sample_doc.docx");
}

private static Footer CreatePageFooter()
{
//Page footer is a RadDocument that is inserted into the main RadDocument
RadDocument doc = new RadDocument();
Section sec = new Section();
sec.Blocks.Add(CreateHeaderFooterTable("Footer text (a)", "Footer text (b)"));
doc.Sections.Add(sec);
doc.MeasureAndArrangeInDefaultSize();
Footer footer = new Footer() { Body = doc };
return (footer);
}

private static Header CreatePageHeader()
{
//Page header is a RadDocument that is inserted into the main RadDocument
RadDocument doc = new RadDocument();
Section sec = new Section();
sec.Blocks.Add(CreateHeaderFooterTable("Header text (a)", "Header text (b)"));
doc.Sections.Add(sec);
doc.MeasureAndArrangeInDefaultSize();
Header header = new Header() {Body = doc};
return (header);
}

private static Table CreateHeaderFooterTable(string leftString, string rightString)
{
Table table = new Table();
table.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100.0); //fit to page width
//table.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, Unit.InchToDip(tableWidthInches));

table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;

//table.Borders = new TableBorders(new Border(BorderStyle.None)); //set no borders for table - borders will be done at the cell level
table.Borders = new TableBorders(new Border(BorderStyle.Single)); //diagnostic - show single line border//Must use TableBorders() default constructor and then do a .SetBottom(border type) before assigning it to table.Borders
//Border noBorder = new Border(BorderStyle.None);
//table.Borders = new TableBorders().SetLeft(noBorder).SetTop(noBorder).SetRight(noBorder).SetBottom(noBorder);

TableRow row = new TableRow();{
TableCell cell = new TableCell();
cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 50.0);//to set cell borders you have to create a TableCellBorders object with the default constructor and then do a SetBottom(), SetTop(), ... for each of the sides of the cell
//cell.Borders = new TableCellBorders().SetBottom(new Border(1.0f, BorderStyle.Single, Color.FromRgb(0, 0, 255)));

Paragraph par = new Paragraph();
par.Inlines.Add(new Span(leftString));
cell.Blocks.Add(par);row.Cells.Add(cell);
}

{
TableCell cell = new TableCell();
cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 50.0);
cell.TextAlignment = RadTextAlignment.Right;Paragraph par = new Paragraph();
par.Inlines.Add(new Span(rightString));
cell.Blocks.Add(par);
row.Cells.Add(cell);
}

table.Rows.Add(row);return (table);

}

private static void ExportToWordDocx(RadDocument document, string fileName)
{
using (Stream outStream = new FileStream(fileName, FileMode.Create))
{
DocxFormatProvider provider = new DocxFormatProvider();
provider.Export(document, outStream);
}
}
}

C
Top achievements
Rank 1
 answered on 01 Oct 2014
3 answers
382 views
How do you set the size of an inline image added to Word docx document using RadDocument?
We need to add the image to a table and have the image scaled at 100%.  It scales the image at 156% when exporting to Word docx format
Images added outside of a table are sized at 100% and not scaled up.

When we use the following code to add an image outside of a table,.

//Setup RadDocument
RadDocument document = new RadDocument() { LayoutMode = DocumentLayoutMode.Paged };
document.SectionDefaultPageSize = PaperTypeConverter.ToSize(PaperTypes.Letter);
document.SectionDefaultPageOrientation = PageOrientation.Portrait;

const double pageMarginSizeInches = 0.5;
int marginSizeDip = (int) Unit.InchToDip(pageMarginSizeInches);
document.SectionDefaultPageMargin = new Padding(marginSizeDip);

//Add text and other document content

AddImageTable(document);

//add more text and document content//output to .docx file

//write to .docx file
using (Stream outStream = new FileStream("out.doc, FileMode.Create))
 {
  DocxFormatProvider provider = new DocxFormatProvider();
  provider.Export(document, outStream);
 }

//end of program

void AddImageTable(RadDocument document)
{
Section section = new Section();

System.Drawing.Bitmap testImage = ( a 500 pixel by 500 pixel bitmap image taken of an application window)

Table table = new Table();
table.StyleName = RadDocumentDefaultStyles.DefaultTableGridStyleName;
row = new TableRow();
TableCell cell = new TableCell() { PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 20.0f)  };

Paragraph par = new Paragraph();
par.Inlines.Add(new Span("Image test"))

cell.Blocks.Add(par);
row.Cells.Add(cell);

cell = new TableCell() { PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 80.0f) };
cell.Blocks.Add(AddImage(null, testImage, 0.0f));
row.Cells.Add(cell);

table.Rows.Add(row);

section.Blocks.Add(table);
document.Sections.Add(section);
}

static Paragraph AddImage(string imagePath, System.Drawing.Bitmap bitmapImage)
{   //add image from the assembly resource or from a Bitmap
 try
 {
  ImageInline imageTmp;
  Stream inStream;
  
  if (String.IsNullOrWhiteSpace(imagePath) == false)
  {
   inStream = Application.GetResourceStream(new Uri(imagePath, UriKind.RelativeOrAbsolute)).Stream;
   imageTmp = new ImageInline(inStream);
  }
  else
  {
   inStream = new MemoryStream();
   bitmapImage.Save(inStream, ImageFormat.Png);
   imageTmp = new ImageInline(inStream, new Size(bitmapImage.Width, bitmapImage.Height), "png");
  }  

Paragraph par = new Paragraph();
 par.Inlines.Add(imageTmp);  
inStream = null;
 return (par);
 }
 catch (Exception ex)
 {
  System.Diagnostics.Debug.WriteLine("AddInlinePicture() - exception - " + ex.ToString() + "\n\n");
  throw;
 }
}


C
Top achievements
Rank 1
 answered on 01 Oct 2014
3 answers
130 views
Hello,

    When creating a raddocument, if you create a table add it, then create another table right after it, the expected functionality is not there.  Using the sample code found at "http://www.telerik.com/help/wpf/radrichtextbox-features-document-elements-tables.html", moving the creating of the table to a function and then doing the following causes the program to select more than desired.

RadDocument document = new RadDocument();
Section section = new Section();
            
section.Blocks.Add(new Paragraph());
section.Blocks.Add(CreateTable());
section.Blocks.Add(CreateTable());
section.Blocks.Add(new Paragraph());
document.Sections.Add(section);

radRichTextBox1.Document = document;

Now if I hover over the second table, and press the "select all" icon that appear in the upper left hand corner, it will select the table as expected, and the last row of the previous table. 

Since the RadDocument does not support list indenting, before I go to print a document, I have to fake it out by creating a bunch of tables/paragraphs to create this functionality.  So a document that has lets say, 100 tables, if you click in the upper left hand corner, it will crash the program either right away giving a cannot convert error, or after freezing it will wait a bit and then run out of memory.

The above functionality is negated of course if I insert a paragraph in-between tables, however that is not the desired functionality and kind of a waste of resources.

So is there anyway to ensure the grid cannot have the "Select All" icon appear?  If not, is there anything I can do other than inserting something in-between the tables?  If I do have to insert something in-between the tables, is a Paragraph my best bet?

Thanks and Kind Regards,



C
Top achievements
Rank 1
 answered on 01 Oct 2014
1 answer
223 views
Hi,

When the radgridview AddNewRowPosition property NewRowPosition is set to Bottom and the grid doesn't have any items, the add function is hidden. This means I cannot add any new items.
It's working when I set the property to 'Top', but I want the items to be inserted at the bottom..

Is this a known bug? Is there a workaround available?

Thanks,
Jorik
Yoan
Telerik team
 answered on 01 Oct 2014
1 answer
98 views
Hello,

I have a simple application containing a RadGridView with the ItemsSource binded to an ObservableCollection of elements. I use the RowLoaded event to set the background of the cells and it works fine.
Here is the code i use in the RowLoaded:
            string colorStr = "#5cfc56";
            SolidColorBrush b = new SolidColorBrush();
            b.Color = (Color)ColorConverter.ConvertFromString(colorStr);
            var cell= (from a in e.Row.Cells where a.Column.UniqueName == "a" select a).FirstOrDefault();
            cell.Background = b;
            cell.ToolTip = "aaaas";

The problem is that when i refresh the ObservableCollection with new elements the grid does not apply the background color to the rows in spite of launching the RowLoadedEvent however the Tooltip of the cell works.

Is there something i'm doing wrong here?


Tanks.







Yoan
Telerik team
 answered on 01 Oct 2014
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
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?