.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

panels width equal to the parents width ???

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :WPF

I have my own panel class ksClass and I want to insert a ksPanel in a form and the width of the ksPanel shold just be thw same as the width of the form !

        private void Form1_Load(object sender, EventArgs e)
            this.Controls.Add(new ksPanel());

In the class I have this code:

    public ksPanel()
      Panel aPanel = new Panel
        Location = new Point(0, 0),
        Size = new Size(this.Parent.ClientSize.Width, 20),
        BorderStyle = BorderStyle.FixedSingle

but gets an unhandled NullReferenceException !

How can I then set the width of my panel to the "width" of the form it's inserted on ?


Best regards KSor, Denmark

View Complete Post

More Related Resource Links

Disk Stripe Width

Since SQL Server uses 64K pages, isn't it MORE advantageous to use a larger stripe width, say, 1MB?  This would allow for multi-page reads. Doc  

getting the width of a text

a markup extension for getting the width from the number of characters in a text   public class TextWidthExtension : MarkupExtension { static TextWidthExtension() { try { var culture = CultureInfo.GetCultureInfo("en-us"); var font = Application.Current.TryFindResource("_Font") as FontFamily; var typeface = new Typeface(font, FontStyles.Normal, FontWeights.Normal, new FontStretch()); double fontsize = (double)Application.Current.TryFindResource("_FontSize"); double sum = 0; for (char c = ' '; c <= '~'; c++) { var formattedText = new FormattedText(c.ToString(), culture, FlowDirection.LeftToRight, typeface, fontsize, Brushes.Black); sum += formattedText.WidthIncludingTrailingWhitespace; } AverageWidth = (sum / ('~' - ' ')); typeface = new Typeface(font, FontStyles.Normal, FontWeights.Bold, new FontStretch()); sum = 0; for (char c = ' '; c <= '~'; c++) { var formattedText = new FormattedText(c.ToString(), culture, FlowDirection.LeftToRight, typeface, fontsize, Brushes.Black); sum += formattedText.WidthIncludingTrailingWhitespace; } AverageWidthBold = (sum / ('~' - ' ')); } catch { } }

Does SharePoint support the Full Width Asterisk within urls?

The Full Width Asterisk (U+FF0A) can be entered for folder names in document libraries and file names.  Yet when you attempt to open files with this character, or files in a folder with this character, the url does not resolve. I have tried all of these, but none work. http://server/Shared%20Documents/%EF%BC%8A/Test%20Document.txt http://server/Shared%20Documents/%uFF0A/Test%20Document.txt http://server/Shared%20Documents/*/Test%20Document.txt

How to set the width of column on GridView

How to set the specific the width of each column, the columns are created automaticly 

What is the best way to nest Listviews together and have all listivew columns retain the same width

I have 3 listviews that I need to be come one.  Each listview has a different source, but information from each is used in the other for totals. I have no problem nesting the listviews one after another to look as if they are actually one listview in the end, but I need to figure out a way to make the  columns identical.  What is the easiest way to do that? Thanks 

How can I set the width property the LayoutTemplate in a listview through codebehind

Taking the following simplified layout for a listview, how do I get and set the width property of the columns. Using Codebehind, how do I set the width of Th2 to Th1. <LayoutTemplate> <table ID="itemPlaceholderContainer" runat="server"> <tr ID="Tr1" runat="server"> <th ID="Th1" runat="server"> </th> <th ID="Th2" runat="server">                         </th> <th ID="Th3" runat="server">                         </th> </tr> </table> </LayoutTemplate>    

WPF control size is larger than explicitly set width and height values.

I created a Canvas with fixed Width and Height (256x256). Next to it I put an Image control displaying a 256x256 texture without stretching. How is it possible that actual sizes of both controls on the screen differ so much? Here - is the screenshot illustrating size mismatch. And here - the TestLines256.png in case someone liked to check it (and maybe point out that I'm stupid and this texture is 180x180 and not 256x256 as I claimed). XAML with creation of the controls:   <Window x:Class="OversizedQuad.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" SizeToContent="WidthAndHeight"> <StackPanel Orientation="Horizontal"> <Canvas Width="256" Height="256" Background="Red" /> <Image Stretch="None" Source="TestLines256.png" /> </StackPanel>

Specify width on EditorFor input field

I happily use the new variant of TextAreaFor that allows me to specify the width for the field. TextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, Int32, Int32, Object) Is there any way I can set the width when using an EditorFor or TextBoxFor method? 

How to change the size (width) of scorecard columns in Dashboard Designer?

Is there any way to change the size (width) of scorecard columns in Dashboard Designer?

WPF: Adding checkbox with content Textblock at dynamically - width width returns NaN

I want to add set of checkbox at runtime one by one in one column. So i am creating check box object with content Textblock (Textwrapping = wrap) and adding to wrappanel but width of controls is NaN so i am not able to set location(Y co ordinate) of next checkbox. int lastheight = 10; private void btnadd_Click(object sender, RoutedEventArgs e) { CheckBox chk_add = new CheckBox(); chk_add.MaxWidth = 100; TextBlock tb_add = new TextBlock(); tb_add.MaxWidth = 100; tb_add.TextWrapping = TextWrapping.Wrap; tb_add.Text = "Here is long text so that text block will get split over two lines....... blah blah blah"; chk_add.Content=tb_add;     chk_add.Margin = new Thickness(10, lastheight, 0, 0); wrapPanel1.Children.Add(chk_add); lastheight += (int)chk_add.Width; } Can any any one have idea how can i tackle this issue.

WPF DataGrid Column Width issue

I have a simple window with 2 tabs, and 4 datagrids.  I set up each one with similar, if not identical settings.  They all get their own DataSet based binding, and have standard Text columns, and combo box columns.  Recently (past week) of development, while I was adding filtering/sorting/grouping features to my program, the column widths have begun to ingore my settings.  By collapsed I mean approx 20 pixels wide (just enough for the sorting Icon). Contacts datagrid, works great in run time, but in design time the columns are all collapsed. ContactsToClients data grid has no abnormal issues Clients datagrid AND Clients to Contacts datagrid look great in design time, but show collapsed columns in run time. How do I hunt down the problem?  I've tried removing all the temporary code, and rebuilding, closing Visual Studio and reopening.  I've remmed out the sorting code.  None of these have any affect.  It appears that my settings are all being ignored.  Here is the XAML code:   <Window x:Class="wdContacts" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:my

Sharepoint 2010 page width

I am trying to set up sharepoint site 1024 x 768, I have tried css body.v4master, body #s4-workspace, I am getting a horizontal scroll bar in the bottom I am trying to build a custom layout page, help me out thank you Neel

How to make bold/regular font text the same width

Hi! In Excel the width of texts in bold font cells have the same width as regular font ones. My question is how to do that programmatically (in a DataGridView, labels, paint event, anywhere...). I can do this if I draw the string twice in the paint event (1 pixel shift for the second draw), but it requires 2 drawings of course, which I think is not too efficient. Is there any other solution? Some trick in creating the bold font? Thank you, Feri

How to Control each cells width and height of a Table ?

Hi, I want to fix the size of each cells of a table . for that i used Style like this: <td style="width:10px;height:10px"> contents </td> But it seems that there is no any effect of applying these settings.How can  i set its width and height. It seems that it purely depends on the contents of cells. Now, if suppose there are two rows, <tr id='r1'> <td id='d1'> content of size 10px </td> <td id='d2'> content of size 10px </td> </tr> <tr id='r2'> <td id='d3'> Content of size 400px </td> <td id='d4'> content of size 20px </td> </tr>   Then cell of id 'd1' will get a size of 400px ,since its just below cell is of size 400px. I want to fix its size. Is that possible ?  

How to auto set forms width automatically on different versions of windows OS.

How to auto set forms width automatically on different versions of windows OS.My application running on Windows Server 2000 Pops a new windows forms side by side the MDI and fits without overlapping.  When the same application is hosted on Windows Server 2008 and the new window pops up, it is overlapping on the existing MDI.

Setting Width & Height on a WriteableBitmap

I am using a WriteableBitmap to convert System.Drawing.Bitmap - it seems to work nicely when I set the rect to 1024x768 like this: wbm.AddDirtyRect(new Int32Rect(0,0,1024,768); What if I want it to be dependent on screen resolution - if I do that, then it does not draw the Image fully - Any ideas on how to get it working for any resolution?

How to change a Left Navigation width in sharepoint

Hello,   Any body help me out how to change or modify the width of left navigation..   thank you  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend