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


Top 5 Contributors of the Month
Abhijit
Post New Web Links

DataGrid cell content with suffix - editing

Posted By:      Posted Date: November 25, 2010    Points: 0   Category :WPF
 

Hi,

I have a DataGrid in which i specify some converters in order to add suffixes to cells.

For example column of numbers that represent minutes i add " mins" to each cell.

 

Now when i edit the cell, i want the " mins" suffix to dissapear for the editing process and reappear when exiting edit mode. So that the user wont be able to change the "mins" suffix.

 

Cant figure a way to do it.

Please help.

Thanks




View Complete Post


More Related Resource Links

Get Cell Value of DataGridComboBox Column for WPF DataGrid

  
hello Friends I am using WPF Datagrid (WPFToolKit Control) in my appliction I Have a DataGridComboBox Column which is filled with some records.  <WpfToolkit:DataGridComboBoxColumn ScrollViewer.CanContentScroll="True" CellStyle="{StaticResource LeftAlignedCellStyle}" Header="Item Code" x:Name="CmbItems" Width="250" SelectedValueBinding="{Binding ITEMCODE}" DisplayMemberPath="ITEMDESC" SelectedValuePath="ITEMCODE"  > </WpfToolkit:DataGridComboBoxColumn> Now how to get selectedText of that combobox for current row. my current focus on other cell  Please Help Me regards Vipul

Changing Datagrid Cell foreground colour depending on previous value

  

Hi,

I have a datagrid bound to a observable collection and a background thread is regularly updating the collection when an event is fired.( subscribed to a market data service) . I need to change the foreground of the cell value if (Previousvalue > NewValue) . I guess I need a conveter but how can I get access to the previous value ? Or is there a smarter way to do this. Performace is a concern as well.

Thanks v much.

Vijay


WPF: how to change the ListView cell template if the content is too long, it will display as Charact

  

We have used the GridView inside the ListView. We fix the column width (see the following link):

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/7b66d9e0-36e0-4c63-b700-eb0a94fda5ac

if the content is too long in one cell (since we fix the column width), we want it display as CharacterEllipsis at the end

just like the TextBlock we can define TextTrimming="CharacterEllipsis"

how can we achive it?

 

we have used the ListViewItemStyle as following, can we modify the <GridViewRowPresenter  /> section to achive it?

<Window.Resources>
  <!--ItemContainerStyle with the Trigger for selection x:Key="ListViewItemStyle"-->
  <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
   <Setter Property="Background" Value="Transparent"/>
   <Setter Property="HorizontalContentAlignment" Value="Center"/>
   <Setter Property="VerticalContentAlignment" Value="Center"/>
   <Setter Property="Foreground" Value="Black"/>
   <Setter Property="Margin" Value="5,0,5,0&q

handle up & down keys while editing a cell in datagridview to affect listbox

  

I have a datagridview. i have overridden some datagridview methods to capture enter key and updown key in a separate class

ProcessDialogKey()

ProcessDataGridViewKey()

i also have a listbox. while i am editing a cell the listbox is being visible and searching in the listbox for what is in the cell's textbox. (i am also able to catch the up down key but from a different class which overrides some methods.)

Now what i need is when i press up and down key the listbox's selected items will change accordingly.

Plz help me to solve it.


How to change the datagrid cell background color linear to the value

  

Hi,

I have a WPF 4.0 Datagrid displaying order values and I need to colour the backgroud of the high value orders so the user will notice high value orders easily. Is it possible to set the colour from white to red but increasing in steps say every 10,000 and increase the colour intensity according to the value.

Many Thanks.

Vijay


How to wrap the Cell in DataGrid? PLS HELP ME

  

Dear all,

Are Anyone know how to wrap the cells in the Datagrid (in WPF) to show long texts wrapped? I tried all the way, but due to lack of experience and knowledge in WPF, I am not able to make it run

I declared following style in the Resources as like below

<Window.Resources>
 <Style x:Key="myGridCellStyle" TargetType="DataGridcell">
 <Setter Property="ContentTemplate">

<Setter.Value>

Create controls inside the datagrid cell based on the datatype uisng WPF

  

I have a requirement that I need to develop a component which should display variable types of data inside a datagrid. The datagrid will have two coulmns. Fisrt column will display the list Captions (like: FirstName, DateOfBirth, IsMarried, Age) and the second column will display the list of data based on their data type, like:

> As FirstName is in string format it should display the value inside a TextBox control on right side of FirstName caption

> As DateOfBirth is in Date format it should display the Date value inside a DatePicker control on right side of DateOfBirth caption

> As IsMarried is in Boolean format it should display the CheckBox control with check state on right side of IsMarried caption

> As Age is in integer format it should display the integr value inside a TextBox Control on right side of Age caption.

If any body has any idea please guide me the way to develop. I request you to kindly help on this for creating this control

Thanks

gps


Cannot set datagrid to readonly while editing

  

Hi all!

Been battling this problem for some time now and could really use some help.

I have an editable datagrid (toolkit version). When a user enters an id nr in one of the cells, my program does a look-up to find the person. While the look-up is in progress, I want the whole window disabled so the user can't tab away and perform other actions.

If I try to set the isenabled flag to false I get: 'NewItemPlaceholderPosition' is not allowed during a transaction begun by 'AddNew'.
I figure it tries to set it to None when disabling.

I've tried to CancelEdit() and CommitEdit() on the datagrid but it fails. Does anyone have any idea how to do this?


KeyUp event on DataGrid cell or column

  

 

Hi,

I've a DataGrid in my wpf, and I'm creating my columns dynamically via code,

i want to handle the key event on the dataGrid column.

how can i handle event on dataGrid column (something like dataGridView has in winforms).

here is an example:

col = new DataGridTextColumn();
            col.Header = "sum";
            col.Width = new DataGridLength(15, DataGridLengthUnitType.Star);
            col.Binding = new Binding("sum");
            paymentDataGrid.Columns.Add(col);

 

Thanks,

Gidi.


Changing crid cell content at runtime

  

In a cell in a grid, I have a TreeView. When the parsing of the data behind the treeview yields an error, I would like to replace the treeview with a textblock with information on the error details.

I'm thinking about using a datatemplateselector, but I can't figure out how, or if this is the best approach. Any suggestions?

Alternatively I will place a ContentControl in the grid cell and populate it with the correct content from the code behind file, I just think there could be a more elegant solution in pure XAML.


Editing the list and view of a content query web part

  

I have added a content query to my site which is querying a master contact list.

Once I have added the web part I then want to customised how it is displayed, i.e. first name, company name etc.

I am not getting a list menu in the ribbon when I check the box next to my content query web part heading.

Can anyone help.


how to get a cell control in DataGrid

  

Dear everyone

i have tried to get a cell control in datagrid, but i can't get it.

 

[Code]

        void SimPle_Loaded(object sender, RoutedEventArgs e)
        {  

        Microsoft.Windows.Controls.DataGridCell cell = GetCell(1, 1);
            TextBlock tb = cell.Content as TextBlock;   // i can't get the textblock, the cell.content have a binding object, not control
            if (tb != null)
            {
                MessageBox.Show(tb.Text);
            }

        }

          //<Output:OutputIO x:Name="WriteOutput" BorderThickness="6" Height="38" Width="150" IO="{Binding Mode=OneTime, Path=IOHandle}"  />

         // because i want to get my usercontro

Setting focus on cell in datagrid after CollectionChanged event.

  

 

Hi!

Having trouble setting the focus on a cell after the collection recieves a new row. This is my code:

		void
 My_DataGridRow_Coll_CollectionChanged(object
 sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
		{
			DataGridRowObjects<My_DataGridRow> oc = (DataGridRowObjects<My_DataGridRow>)sender;
			if
 (e.Action == NotifyCollectionChangedAction.Add)
			{
				//set focus to column 2 of the new row

				DataGridCell cell = my_datagrid.GetCell(e.NewStartingIndex, 2);
				if
 (cell != null
)
				{
				 DataGridCellInfo info = new
 DataGridCellInfo(cell);
				 my_datagrid.CurrentCell = info;
				}
			}
		}



Is there any event that fires after the CollectionChanged? My DataGridRow doesn't have a CellPresenter att this stage and GetCell fails. If I do the same with a button event instead, it works fine.

I just tried to add a dispatcher message instead but that did nothing:

Dispatcher.BeginInvoke(new Action(delegate()
{
  //set focus to column 2 of the new row
  DataGridCell c

Vertical alignment of DataGrid row content

  

Hi,

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 

VerticalAlignment="Center"

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}"
		ItemsSource="{Binding}"
		RowEditEnding

Getting WPF ListView Cell Content

  

Hi,

 

I have a ListView that consists of single column horizontally oriented.

The cells contains textbox bount to a list.

How do I traverse the cells to access each textbox?


How to assign a value to wpf datagrid cell

  

Let say I have a wpf datagrid with 2 columns (ProductID and Description).  ProductID column is a combobox and the Description is a Textbox.  On the SelectionChanged event of the ProductID, I want to assign a value to the Description column.  I need to know how to assign the value to the Description textbox for the row of the combobox that fired the SelectionChanged event.  Can someone please provide a sample code?  Thanks


Categories: 
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