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

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

Dynamically sizing columns while keeping two the same size

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :WPF
I am setting up an interface that has a grid with 5 columns.  Three of those columns have a fixed width.  The other two columns I would like to dynamically size according to how big the grid is (i.e. a * size) and I would like them always equal to each other.  The two pieces of code I have tried follow.  Option A keeps the columns the same size but makes everything as wide as it wants w/ no respect for the size of the grid and Option B allows the two columns to size independently. Option A <Grid Grid.IsSharedSizeScope="True" > <Grid.ColumnDefinitions> <ColumnDefinition Width="14" /> <ColumnDefinition SharedSizeGroup="FirstColumn" Width="200*"/> <ColumnDefinition Width="105"/> <ColumnDefinition SharedSizeGroup="FirstColumn" Width="200*"/> <ColumnDefinition Width="14" /> </Grid.ColumnDefinitions> </Grid> Option B <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="14" /> <ColumnDefinition Width="200*"/> <ColumnDefinition Width="105"/> <ColumnDefinition Width="200*"/> <ColumnDefinition Width="14" /> </Grid.ColumnDefinitions> </Grid>

View Complete Post

More Related Resource Links

dynamically adding sql server columns based on number of files in fileuploader


I want to create a new table to sql database at runtime.  The column names would be "Name", "Date", "Event".  I would also like to have one more column name "Image" but the problem is that since the amount of images will vary, I want the application to count the amount of files in the Multiple fileuploader and then add a image column to the table for the respected amount of files. 

For example if i am uploading 3 files in the multiple fileuploader, the names should be "Name", "Date", "Event", "Image1", "image2", Image3"

I also would like that table name to be name dynamically from the textbox Name when the user enters the information.


I have the following code to make a new table, but I dont know how to name the fields at runtime like previously asked please help!!!


Dim objConn As New SqlConnection("Server=<servername>;uid=<userid>;pwd=<password>;database=master")


set textbox size dynamically in RDLC

in Hi, Can some one tell me how to set the size and location of the text box in RDLC dynamically. I cannot access it code, i cannot use parameters or expressions to set this. Thanks

dynamically create columns from xml

<?xml version="1.0" encoding="utf-8" ?> <mappings root="sound" child="item" delimiter=",">    <mapping pos="0" name="product" type="Element" />    <mapping pos="1" name="partID" type="Attribute" />    <mapping pos="2" name="numberInStock" type="Element" />    <mapping pos="3" name="numberOnOrder" type="Element" />    <mapping pos="4" name="deliveryDate" type="Element" />    <mapping pos="5" name="supplierStreet" type="Element" />    <mapping pos="6" name="supplierCompany" type="Element" />    <mapping pos="7" name="supplierPhone" type="Element" />    <mapping pos="8" name="orderedBy" type="Element" /></mappings>this is my xml file what i need is a table with 9 columns say item,product....orderedBy

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?

Bar-graph style - how to keep columns in relative height of size of "graph"

Hi, I need some input for this and imagined that someone else had seen something like it: I have a box, let's say a grid, where there are some bars in it. These bars could be rectangles in a ItemsControl. The grid has a fixed height and width - but the rectangles' height (and width) are set a from a collection of numbers. These numbers go from 0 to 200 - but in periods the numbers only go from 1 to 10. If I use absolute numbers, the rectangles will be tiny in height or width if the numbers are between 1 and 10 and the Grid is 200 in height and width. How do I make the size of these rectangles relative to the tallest one? I guess I could do some calculations 'behind the scenes' in code, but is that really necessary? Is there no other way? Thanks! --Anders

Viewing columns in a gridview dynamically

I have two tables in my database, one for teachers and another for students. The students table has column for name, admission no., math's, English, computer, agric. Different teachers are responsible for each subject. I have a gridview that shows all the columns, but I want only the teacher responsible for each subject see the columns for Name, Adm_no and his subject only (e.g Agric teacher will only see d column for  Name, Adm_no & Agric) I'm using session as the parameter. 
Pls how do I go about this.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            DataSourceID="SqlDataSource1" AutoGenerateColumns="False" CellPadding="4" 
            ForeColor="#333333" GridLines="None">
            <RowStyle BackColor="#EFF3FB" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Adm_no" HeaderText="Adm_no" 
                    SortExpression="Adm_no" />
                <asp:BoundField DataField="Agric" HeaderText="Agric" SortExpres

Problem with gridview dynamically generated columns and textboxes


Hi All,

 I am using asp.net/c# application. In my application, I have a gridview.

<asp:GridView id ="gv_QuestionList" runat="server"> </asp:GridView>

In Code Behind, I created dynamic textboxes and DropDownLists on RowDataBound.

protected void gv_QuestionList_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)

                if (ObjQMDO.QuestionType == "TextBox")
                    TextBox txt = new TextBox();
                else if (ObjQMDO.QuestionType == "Dropdownlist")
                    DropDownList drp = new DropDownList();
                    drp.DataSource = ObjQMDA.GetQuesTypeValues(QUES_ID);
                    drp.DataTextField = "QTYV_QuesTypeValue";
                    drp.DataValueField = "QTYV_ID";
                    drp.Items.Insert(0, new ListItem("Select One", "0"));

                else if (ObjQMDO.QuestionType == "Radio")

can table size will remain same if any of columns are hidden


Hi all...

im haveing table where columns will hide according to condition but if any of the column is hidden table size must  be same as all columns in table .

i have employeedetails table :



ID Number






columns and rows of grid generate dynamically



i am developing the applicaton, from which i have a grid and that grid i want to use for the insert data,

i have a page default.aspx page, in this i have a dropdownlist, according to selection of the dropdownlist, grid's cols and rows created dynamically in insert.aspx. so in page load of the insert.aspx the grid will automatically have that much of cols and rows and that all cell contain the textbox.

how can i set that dynamically....

please help me....

thanks in advance

waiting for the reply.....

How do I determine the size of a dynamically created set of controls?



How do I determine the size of a dynamically created set of controls?

For example, suppose I have a method that creates a form made up of many TextBlocks, TextBoxes, etc., all contained within a grid and that grid is returned by the method.  I need to determine the size of that grid without adding it to any other controls.

    Grid myForm = myMethodThatReturnsAGrid();

    // Here is where I want to find out the size (height and width) of the grid myForm.

The reason I need the size, mainly the height is to determine if it will fit in what is left of the page of a FixedDocument for a report, and if not, to move it to the next page.




Regards, Robert -- Note: I work on various aspects of one or more programs, working on what is most important at the time. Some questions I ask are on aspects of the program that are not important right now or I'm using a workaround for now. Eventually they'll be high priority again and I'll get back to those answers received and respond accordingly. Those that are high priority get responses very soon. Thanks for your input, it is appreciated.

custom list template columns not in order (not keeping required fields)

I have a template (based on a custom content type) that I got working just the way I want it. All the list forms are in the order I want with the fields showing that I want.  I saved this list as a template and create List#2 from that template, but its forms don't show all the required fields (they don't show on the form), and some items are out of order.  Can anyone explain this to me please?  I am working towards a site definition that needs everything just so.
There are no mistakes; every result tells you something of value about what your are trying to accomplish.

Transposing one row values into Columns Dynamically


Hi I hav a situation where I have to extract data from a table in a dynamic form.

CompanyId   ProfitType     Profit

1                  1                  1000

1                  2                  2000

2                  2                  3000


And the ProfitType table looks like


ProfitTypeId   ProfitName

1                   NET Profit

2                   PreTax Profit

3                   Investment Profit


and  need a query to transpose my profits to look

To add new columns dynamically to sql table via admin side

As you could have guessed, I want to add new columns dynamically (for future quarters) to sql table via admin side. Thinking of providing a text box (column name), drop down (subtypes possible) and add button which will basically add the column. I want to do this in asp.net c#.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

add columns with textboxes in gridview using C#

'm working on a shopping cart in a website and I have my items(which have been added to the cart) in an arraylist. And using these values I've read the rest of the values from the db and and have populated on the gridview successfully.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key
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