Thanks for the link. I used a label control for the heading. That way I could change the alignment and the font. Works fine.
Mark F
Posts
-
Heading text alignment problem -
Heading text alignment problemSorry for the ambiguity. Windows has a ContentAlignment property that aligns the text in a control from TopLeft to BottomRight, and also middles. I know that using CSS you can align textual content using the div as a container. I was wondering if there is a way to use the ContentAligment property values from a Windows form to set the div container css. So if the user selects MiddleLeft the text is aligned that way in the html markup.
Mark
-
Heading text alignment problemI am working on a page that allows a user some control over layout and formatting. I want the user to be able to align the heading of a page just like the Windows Forms ContentAlignment property. For example: TopLeft, MiddleLeft, BottomLeft, MiddleTop, and so on.
Thanks, Mark
-
Checking for valid xml file.Does such a thing require adding a new namespace?
Mark
-
Checking for valid xml file.Before you read on, this is not about checking for valid XML syntax or schema. I would like to be able to check if the user is opening an XML file that has data for my application only. If they try to open any other XML file the application should warn them. The XML file data is serialized via XmlSerializer.
Thanks, Mark
-
XPathNavigator iterate and writeThe xml is displayed in a TreeView control so alphabetical sorting by 'name' attribute was necessary. I worked out something similar to your reply and problem solved. Haven't had a prior occasion to use Linq however. Thanks for the help!
modified on Friday, December 3, 2010 3:28 PM
-
XPathNavigator iterate and writeI am using XPathNavigator to sort nodes by name. Is there a method for writing the sorted nodes to the same or different file?
foreach( XPathNavigator item in navigator.Select( expr ) ) { // write to new document here..., }
Thanks, Mark
-
Form data printing problemI'll give it a try. Thanks!
-
Form data printing problemLuc Pattyn wrote:
you should set PrintPageEventArgs.HasMorePages;
I already thought of that. I also thought of setting the printrange to currentpage and then repeatedly call Print. Even that failed.
pagesLeft = this.Print( e ); if ( pagesLeft < cardsToPrint.Count ) { e.HasMorePages = true; } else e.HasMorePages = false;
The Print() method calls Graphics.DrawString() and draws the strings on the PrintDocument graphics rect. For a single page it works perfectly.
-
Form data printing problemI created a UserControl that contains three RichTextBox controls. I added a PrintDocument property, and the methods required to print (Print, PrintPage, BeginPrint, etc). I have a loop that iterates the data and loads three strings in the RichTextBox controls, one to each control, and then calls PrintDocument.Print(). It should then print that page and get the next three strings of data to print. This works fine for the first page, but the other pages don't print. After calling PrintDocument.Print() the program returns to the main form that called the UserControl print method. How do I continue iterating through my loop to print more pages?
-
PrintDocument clipping / wrapping text problemI figured it out after I found a reference that states: when passing a RectangleF as one of the parameters, DrawString automatically wraps the text inside the destination's bounding rectangle. So I changed by method call to:
RectangleF cardBox = new RectangleF( rich.Bounds.X + 5, rich.Bounds.Y + 5, rich.Bounds.Width - 5, rich.Bounds.Height - 5 ); g.DrawString( rich.Text, rich.Font, Brushes.Black, cardBox, frmt );
The 'cardBox' rectangle is deflated by 5 pixels for padding. I also included a StringFormat to center the text on the card.
Mark
-
PrintDocument clipping / wrapping text problemI have the following code which prints three RichTextBox controls to a page. The format is Avery 5388 which is the perforated index card stock paper (8.5x11). The print preview shows the text in each box but the lines don't wrap. Any way to fix the wrapping problem?
private void fcPrintDocument\_PrintPage( object sender, PrintPageEventArgs e ) { cardDataTabPage.Focus(); DrawPage( e.Graphics ); } private void DrawPage( Graphics graphics ) { Graphics g = graphics; Pen boxPen = new Pen( Brushes.Black ); int pageWidth = fcPrintDocument.DefaultPageSettings.PaperSize.Width; int pageHeight = fcPrintDocument.DefaultPageSettings.PaperSize.Height; RectangleF srcRect = cardDataTabPage.ClientRectangle; RectangleF destRect = new Rectangle( 0, 0, pageWidth, pageHeight ); float scaleX = destRect.Width / 850; float scaleY = destRect.Height / 1100; for ( int i = 0; i < cardDataTabPage.Controls.Count; i++ ) { if ( cardDataTabPage.Controls\[i\].GetType() == richTextBox1.GetType() ) { RichTextBox rich = (RichTextBox)cardDataTabPage.Controls\[i\]; g.DrawRectangle( boxPen, rich.Bounds ); // draws 3x5 box where card should be g.DrawString( rich.Text, rich.Font, Brushes.Black, rich.Bounds.Left \* scaleX, rich.Bounds.Top \* scaleY, new StringFormat() ); } } }
Thanks.
-
Problem getting propery values with ProperyInfoYes I have overloaded the ToString method. Below are the methods in my CustomColor class. My ToString method was incorrect!
// This method is incorrect and ..., public new string ToString() { return string.Format("{0:X2}{1:X2}{2:X2}", \_Red, \_Green, \_Blue); } // Should be... public override string ToString() { return string.Format("{0:X2}{1:X2}{2:X2}", \_Red, \_Green, \_Blue); }
Thanks for the help! Mark
modified on Monday, March 1, 2010 11:53 AM
-
Problem getting propery values with ProperyInfoI have a custom class TableProperties which has properties for CSS table styles. I have a CustomColor property that has a UITypeEditor to display the ColorDialog control and then convert the color value to a hex string (e.g., ffffff). When I iterate through the PropertyInfo collection the GetValue method returns the property type rather than the value.
// Loop which displays the properties in a ListView control (Testing only). foreach (PropertyInfo pi in tableProperties.GetType().GetProperties()) { name = pi.Name; ListViewItem lvi = listView1.Items.Add(name); theType = pi.PropertyType.ToString(); lvi.SubItems.Add(theType); // this returns 'TblPropTest.CustomColor' rather than 'ffffff' value = pi.GetValue(tableProperties, null).ToString(); lvi.SubItems.Add(value); }
The PropertyGrid works fine with the custom properties. Thanks, Mark
-
PropertyGrid and Custom propertiesI think you misunderstood my question. I need to add an expandable property like the Font property has when displayed in a PropertyGrid. MyProperty Category + MyProperty my property's value string Size size value color color value name name value etc...., How is this done? Thanks, Mark
-
PropertyGrid and Custom propertiesI have a custom property that has two string values and an int value. I need to display them in a PropertyGrid so that the property's UITypeEditor edits any of the three properties within that type. An example would be the "Font" type in a PropertyGrid. The name, size, unit, bold, etc. is part of the editor for that property type. Is PropertyDescriptor what I need? Thanks, Mark
-
Saving text file with StreamWriterAfter the text file was saved a webbrowser control attempted to navigate to the local document path. Since it's css Frontpage opened the file by default. This error was not readily apparent at first. >>>>>>>> :doh: Mark
-
Saving text file with StreamWriterFrontpage is not running, and I am simply editing a .css document (text) in a RichTextBox. I doesn't make any sense that Frontpage opens after the file is saved in the RichTextBox control! Mark
-
Saving text file with StreamWriterAnytime I open or save a .css file using RichTextBox.LoadFile() or .SaveFile() methods Frontpage opens the file. So I write the contents to disk using the following. Even so, Frontpage still tries to open the file!
try
{
using (StreamWriter writer = File.CreateText(path))
{
foreach (string line in rich.Lines)
writer.WriteLine(line);
}
}
catch (IOException e)
{
// error handling here
}Mark
-
MenuStrip and ToolStripButton corruptionThanks, I'll give it a try.