.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

Datagrid CellStyle vertical align problem

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :WPF

Im using the WPF toolkit when I set a textcolum cell style to align the text to the center vertically it becomes very hard to select the text

without the cellstyle I can just click anywhere in the cell and begin editing the text in there, but with the cellstyle you have a very limited area in the cell where you can select the text field

does anyone have any way to fix this?

                      <Style TargetType="{x:Type dg:DataGridCell}">
                          <Setter Property="VerticalAlignment" Value="Center"></Setter>

View Complete Post

More Related Resource Links

problem with datagrid

I am trying to create datagrids dynamically using Datagrid Array.But I am getting exception while setting Datasource.  Do anybody have the solution for this? Code  using(SqlDataAdapter da =new SqlDataAdapter(cmd1))      {       DataSet ds =new DataSet();       da.Fill(ds);              for(int i=ds.Tables.Count;i >=1;i--)       {        int j=ds.Tables.Count;        DataGrid[] dgd=new DataGrid[i];        DataGrid DataGrid[i]= new DataGrid();        DataView dv1=new DataView(ds.Tables[i-1]);        dgd[i].DataSource=dv1;//    Exception        dgd[i].DataBind();        plh1.Controls.Add(dgd[i]);       }      } 

DataGrid cells ImageUrl properties problem

At the outset i would like to welcome all as this is my first post on this forum :) probably i've got a simple problem for most of you, namly:   I want to dynamically replace ImageUrl into DadaGrid cell. I've already prepare a right type of field (Image Field) and this is my code:   Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.Cells(3).Text = "1" Then e.Row.Cells(3).Text = "Online" DirectCast(e.Row.Cells(4).Controls(0), Image).ImageUrl = "~/Css/green.png" 'e.Row.Cells(9).ForeColor = System.Drawing.ColorTranslator.FromHtml("#489A38") 'e.Row.ForeColor = System.Drawing.Color.LightGray Else e.Row.Cells(3).Text = "Offline" DirectCast(e.Row.Cells(4).Controls(1), Image).ImageUrl = "~/Css/red.png" End If End If End Sub And i.ve got this error: Specified argument was out of the range of valid values.Parameter name: index Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and whe

Vertical Align Menu Items when RenderingMode=List


I am having problems getting my Menu Items to align vertically in the middle when I set my rendering mode = list.

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="list" CssClass="AspNet-Menu">
                <asp:MenuItem NavigateUrl="#" Text="Menu 1" Value="Menu 1"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 2" Value="Menu 2"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 3" Value="Menu 3"></asp:MenuItem>

css code for list

/* MENU */

.AspNet-Menu ul li{ width:60px; height:30px; background-color:Silver; vertical-align:middle;}
.AspNet-Menu ul li a
	color: Red;

But if i set the rendering mode to table it works fine...

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="table" CssClass="AspNet-Menu">

Table td align center with width problem


Hi, can you please tell me why the alignment isn't working:


<table border="1" width="700px">
            <td align="center" width="14px">
1 </td> <td align="center" width="14px">
<td align="center" width="14px"> 3 </td> <td align="center" width="14px"> 4 </td> <td align="center" width="14px"> 5 </td> </tr> </table>


but when i remove the width from all the tds, the align will work.


Vertical align table cells via SharePoint UI



Is there anyway to vertical align table cells via the sharepoint 2010 WSIWYG editor? From what I can tell, you have to go into the html to do this, but you can't really tell end users to do this, especially for something that's quite a common request. Is there a way that i'm unaware of?

btw the main place where we need this ability is while using the PublishingWebControls RichHtmlField control.


Problem with css vertical alignment



I want to create a box, that looks and acts exactly like in this image (I have edited it in photoshop to make it look like what I want):


As you can see, the heading should be vertically middle aligned. And if the text exceeds the width, the text should then take up the place like normal behaviour.

Ive tried to accomplish this for a long time now, but cant get it right! Problem is that I cant make the text vertically align, since I´m using the display:block;

Here is what i have:


<div class="outer">
  <span class="heading" >Long heading that should take up all the place, but not expand the box </span>
  <div class="inner">
  <b>Description</b><br />just some random text<br />blablabla<br />


  border:1px solid #797979;


Vertical alignment of DataGrid row content



I have a regular DataGrid from WPF 4.0 RTM, where I put data from database. In order to make clean & light style of DataGrid I use a tall/high rows and by default DataGrid aligns row content in top vertical position, but I want to set a center vertical alignment.

I already tried to use this property 


in DataGrid options, but it doesn't help me.

Here is an example of XAML-code, describing my DataGrid without center vertical alignment:

<DataGrid x:Name="ContentDataGrid"
		Style="{StaticResource ContentDataGrid}"

datagrid with adjusting Vertical scroll bar



here my requirement is datagrid scrollbar which is smaller than the datagrid height...

I need little scrollbar at top vertical possition...

Can u help in this....

WPF datagrid Tab Navigation problem not following tab index order



I have designed a wpf page with 3 textbox than a datagrid than again a text box

and I have set the tabindex to first 3 testbox 1, 2, 3, than 4 to datagrid and 5 to last testbox

But when I run page and press tab to navigate,first three textbox are ok they follow tabindex but when I tab to navigate to datagrid it jumps to forth textbox and again on next tab go to datagrid. means after navigating all of the four textbox its go to girdview.

Please tell me how I can set tab order?

browser compatibility problem with datagrid with fixed header using CSS way


Hi Everybody,

I am trying to create a datagrid with fixed header and I was using the CSS way to implement this using:


However, this only works in IE and not in FF. The other alternative that I found was to create the header in a separate table and to use scrollbars on the datagrid. But, I want to stick to the first option and want to make it work on both browsers. The problem is I don't know how. Any inputs on this is greatly appriciated.


WPF datagrid Tab Navigation problem not following tab index order



I have designed a wpf page. But I not able to set Proper Tab Navigation on it. Controls (Specialy datagrid) on the page are not following tab index. 

It has a group box inside which there is a grid. this grid has rows and columns. In first three rows contains textboxes. 4th row contains  the datagrid forth row spans to 5 cols. in next row it agains has textbox and after that it has 3 buttons

Following is the design view, Run time view with tabindex which I have given to them and arrows show the index they are following.

I am loading datagrid with a object of list of items which has one object of type item. so as per my thinking it is not empty it has data in it. as you can see in run time view

Datagrid with Combobox Lookup (CollectionViewSource) -- Problem Saving Combobox Changes


I've developed a simple WPF application consisting of a four-column datagrid.  One of the four columns is a combobox that looks up by an id into a second table.

I can make changes to the other columns and they save just fine.  When I make a change to the combobox, it's not changed in the database.

I'm either missing something in the SelectionChanged handler or totally missing something else.

I've googled to the nth degree and haven't found any definite answers.

Any ideas?



Cindy Rae



<Window x:Class="trialWWSF2.MainWindow"
        Title="MainWindow" Height="403" Width="525" xmlns:my="clr-namespace:trialWWSF2" Loaded="Window_Loaded">
        <my:WWSF x:Key="wWSF" />
        <CollectionViewSource x:Key="categoriesViewSource" Source="{Binding Path=Categories, Source={S

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Use Jquery with repeater, gridview, datagrid

Before we talk about jquery inside any itemtemplate (repeater, gridview, datagrid), we need to understand the basic use of jquery functions

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

ListBox tricky to set in a DataGrid/GridView

Listboxes are very tricky to set selected items in grid - there is no real nice way to do it. It would have been great if Microsoft included a property that accepts an array or comma separated values - or anything! But they only allow each item in the list to be selected individually. The way to do this in a grid is a bit messy, but it is fairly simple to implement. When a row is created (as per the event), select the items of the listbox as per the datagrid source data:

How to highlight datagrid or GridView row on mouse over?

This article will show how you can Ajax with GridView to display popup messages when mouse moves over certain column. In the demo project I have added first column as an image column with a help icon in it. This kind of implements a feature that if you want more information about the row you can move mouse over this icon, a asynchronous request is sent to server for data about that row and when call returns the returned message is show as a popup message.
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