Menu
  • HOME
  • TAGS

Using the FooTable plugin with the ASP.NET DataGrid

asp.net,vb.net,gridview,datagrid,footable

Even if it's harder to implement the FooTable plugin with the DataGrid than with a GridView, it does not means it's not possible. If you read a little bit the FooTable introduction page, you realize that this plugin works with the HTML table element. So, no matter the control you...

Edit DataGrid Cell on mouse over

c#,wpf,datagrid,triggers,datagridcell

I would add an EventSetter in a Style like this : <DataGrid.Resources> <Style TargetType="{x:Type DataGridCell}"> <EventSetter Event="MouseEnter" Handler="EventSetter_OnHandler"/> </Style> </DataGrid.Resources> Here is the handler: private void EventSetter_OnHandler(object sender, MouseEventArgs e) { DataGridCell dgc = sender as DataGridCell; TextBox tb = Utils.GetChildOfType<TextBox>(dgc); tb.Focus(); } In fact you said you want to...

BindingExpression path error on datagrid

c#,wpf,datagrid

You Button's DataContext is the DataItem of the DataGridRow it is in . <Button Command="{Binding Path=DataContext.DeleteStorage, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}}"> ...

MultiBinding with Multiple output

c#,wpf,mvvm,datagrid,imultivalueconverter

The weirdness of that design aside... No, you cannot The signature of Convert is: Object Convert( Object[] values, Type targetType, Object parameter, CultureInfo culture ) (MSDN) So you have to return a single object. That object could even be a Tuple<string, object> which would approximate multiple return values, but thats...

Datagrid textblock not aligned on left border

c#,wpf,xaml,datagrid

From your screenshot it does not seems the TextBlock are "slightly on the right" (they touch the left border). Do you want to get rid of the "row selector", the small gray button on the left? If so set HeadersVisibility="Column" in XAML.

WPF + XAML + DataGrid + Powershell 2.0

wpf,xaml,powershell,datagrid

By default PowerShell 2.0 will use .NET framework 2.0. There is no DataGrid in .NET v 2.0. Type : [environment]::Version If you get this, or something else starting with 2... Major Minor Build Revision ----- ----- ----- -------- 2 0 50727 7905 Your PowerShell session is using NET 2.0. How...

How to remove EditSettings button from filter cell in DevExpress DataGrid

c#,wpf,datagrid,devexpress

As it turned out, I've been using the wrong approach. You have to use CellTemplate instead of the EditSettings: <dxg:GridColumn.CellTemplate> <DataTemplate> <dxe:ButtonEdit Name="PART_Editor" AllowDefaultButton="False"> <dxe:ButtonEdit.Buttons> <dxe:ButtonInfo Content="X"/> </dxe:ButtonEdit.Buttons> </dxe:ButtonEdit> </DataTemplate> </dxg:GridColumn.CellTemplate> ...

Validating texbox control within gridview

c#,winforms,datagrid,.net-4.0

if what you have are DataGridViewTextBoxCells instead of TextBoxes you could use this method static bool IsAnyCellEmpty(DataGridView gridView, params int[] columnIndexes) { bool result = false; foreach (DataGridViewRow row in gridView.Rows) { foreach (var index in columnIndexes) { if (row.Cells[index].Value.ToString().Trim().Length == 0) { result = true; break; } } }...

Accessing complex object properties in a class initializer C# WPF

c#,wpf,linq,datagrid

The problem here is that you are assigning null value to float, which is not a nullable type (see Nullable Types). Either use float? or change the way that you assign the value, so that you handle the case when it is null....

Custom WPF DataGrid with optional button column

c#,wpf,xaml,datagrid,custom-controls

I had to remove the section from the Generic.xaml style for the DataGrid to properly layout and created the column in code. protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); CloneColumn.Visibility = ShowCloneColumn ? Visibility.Visible : Visibility.Hidden; } private DataGridTemplateColumn _cloneColumn; private DataGridTemplateColumn CloneColumn { get { if (_cloneColumn == null)...

css specify first tr in table asp.net datagrid

asp.net,css3,datagrid,html-table,internet-explorer-10

Try changing your css selector to be something like table.maintbl tbody tr:first-child In your original selector, it was looking for the .maintbl element, then a child table element, then tbody, then tr. Now it is looking for a table element with the .maintbl class (and then looking for child elements...

Setting AlternatingRowBackground for DataGrid with Templated DataGridRow

wpf,datagrid,styling

The gray rectangle is the so called row Header. By default the DataGrid turns on row and column header. You turn it off the row header by setting HeadersVisibility=Column So, you don't need a template to get that done....

DataGridRowTemplateColumn - refactoring and using styles efficiently?

c#,wpf,xaml,datagrid

Does this work...? <DataGrid x:Name="CurrentConfigDataGrid" ItemsSource="{Binding}" > <DataGrid.Resources> <ResourceDictionary Source="../ResourceDictionaries/MergedDictionary.xaml" /> <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}" /> </DataGrid.Resources> ... Technically, if you create a Style in your Resources, with no Key but with a TargetType, it should be applied automatically to all controls of that type that have no explicit...

In a WPF datagrid, how do I get the new row after cell edit?

c#,wpf,datagrid

As its name hints, the CellEditEnding event gets fired right before the edit is commited. Sadly, since there is no CellEditEnded event, there's no straightforward way to do what you want. You have three options here: Set the cell's Bindings UpdateSourceTrigger to PropertyChanged, so the changes are applied on the...

Bind a WPF datagrid column header to property in code behind

c#,wpf,xaml,binding,datagrid

Some things are tough to bind because they are not part of the Visual tree, such as popups or in your case - datagrid headers. A well known workaround is to use Josh Smith's DataContextSpy. Basically you instantiate it as a resource and give it the binding. Then use that...

SELECT * FROM giving other result then SELECT 2010,2011 FROM

php,mysql,datagrid,livecode

This part of your code SELECT 2010,2011 From the manual http://dev.mysql.com/doc/refman/5.1/en/identifiers.html "Identifiers may begin with a digit but unless quoted may not consist solely of digits." wrap those column names in ticks. SELECT `2010`,`2011` Since you didn't post your error message. Sidenote: Copy/paste it from this answer. Ticks and regular...

IValueConverter does not pick up a change in bound collection

c#,wpf,xaml,datagrid

Your Converter code will be called when you will notify the Issues property. So try to notify Issue property whenever you are adding/removing any item to that collection. I think it should work.

WPF Bind ListBoxItem to DataGrid

c#,wpf,datagrid,wpf-binding

Solved the issue doing this: 1) Adding this: public DataTable StatisticsDataTable { get; private set; } 2) Then changing my method part here: StatisticsDataTable = dt; GridStatistics.DataContext = StatisticsDataTable; 3) The XAML binding became the following: ItemsSource="{Binding}" Thanks everyone who tried to help!...

DataRowView object getting null value at time of getting value from DataGrid

c#,wpf,xaml,datagrid

Do not use DataRowView ... that is not relevant for WPF's DataGrid. You must be thinking of a different framework. If you are populating the data on your DataGrid simply by setting the ItemsSource property to a collection of objects that you got from your Linq code, then the type...

WPF, DataGrid, clicked item/row does not highlight (blue background)

c#,wpf,linq,datagrid

Here is the solution that works: private void tabControlOrganizer_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (tabControlOrganizer.SelectedItem != null) { if (e.Source is TabControl) { if (tabItemTrades.IsSelected) { dataGridTrades.ItemsSource = Queries.GetTradeList(dataContext); } SelectionChanged was the problem: In C# WPF, why is my TabControl's SelectionChanged event firing too often? In free time I...

SelectedRow and DataBoundItem in WPF as it gets?

c,wpf,datagrid

Assuming the UI for your DataGrid is something like this: <DataGrid Name="dataGridPrincipal" Grid.Row="0" ItemsSource="{Binding MyList}" SelectedItem="{Binding MyItem , Mode=TwoWay}" /> and the code behind is as follow: public ObservableCollection<Customer> MyList { get; set; } public Customer MyItem { get; set; } // with INotifyPropertyChanged implemented public MainWindow() { InitializeComponent(); MyList...

Updating Database On CheckBox Check/Uncheck Event

c#,asp.net,checkbox,datagrid,webforms

I use this to do the same thing. You should be able to do the same thing slightly modifying fieldnames. CheckBox chkStatus = (CheckBox)sender; GridViewRow row = (GridViewRow)chkStatus.NamingContainer; string cid = row.Cells[1].Text; bool status = chkStatus.Checked; //Connection & Call go here com.Parameters.Add("@Approved", SqlDbType.Bit).Value = status; com.Parameters.Add("@CategoryID", SqlDbType.Int).Value = cid; ...

MVVM pattern: an intermediate View between Command binding and ViewModel execute

c#,wpf,user-interface,mvvm,datagrid

You can define another Model and ViewModel for Process Options, and then in the SamplesAnalyzeCommand, display the ProcessOptionsView. When user is done with the ProcessOptionsView, the main ViewModel gets notified (e.g by an event handler) and completes the Process. Something like this: internal class SamplesAnalyzeCommand : ICommand { ... public...

Structure of WPF DataGrid - change cells depending on value

c#,wpf,datagrid

I have been trying another solution for your problem. <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=., RelativeSource={RelativeSource Self}, Converter={StaticResource DataGridCellToBooleanConverter}, ConverterParameter=IsEnabled}" Value="True"> <Setter Property="Background" Value="Yellow"/> </DataTrigger> </Style.Triggers> </Style> <DataGrid CellStyle="{StaticResource DataGridCellStyle}">...

Databinding ObservableCollection to Datagrid not working

c#,wpf,data-binding,datagrid,observablecollection

With the new code provided, it looks like you'd just need to add a PropertyChanged notification for the PostBack property. Since that property is calculated, it won't be recalculated automatically unless you notify it's changed. And you should do so in the Ticker setter because PostBack depends on its value....

c# MVVM update Datagrid after combobox selection

c#,wpf,mvvm,data-binding,datagrid

First thing, as you are using MVVM, so you will have to notify your properties by implementing INotifyPropertyChanged interface. Second from the Setter of your SelectedItem property you will have to notify your WorkItems property as well, so that when you change the date from dropdown, it will also update...

Change DataGrid cell value in VB6

datagrid,vb6

The technology (VB6) is indeed very old; you can try something like Sub AddSymbol() For i = 1 To DataGrid1.Rows If DataGrid1.Item(i, 2) = 1 Then DataGrid1.Item(i, 2) = "*" Next i End Sub where quantity is stored in the second column of DataGrid1 control. Hope this may help....

Updating DataGrid causes GUI to hang?

c#,wpf,datagrid,.net-4.0

Whenever the GUI thread blocks and the application freezes, I would recommend refactoring to use async/await. Essentially, you can push the heavy lifting onto a background thread using something like var result = await Task.Run (() => { return MySlowMethod();});. result is a List<T>, and MySlowMethod is some slow method,...

WPF: Binding the items in a “sub-list” of a list

c#,wpf,xaml,binding,datagrid

The following should work. For example for your first item of the subcollection. Or you could try out binding the entire subcollection to a combobox? <DataGrid.Columns> <DataGridTextColumn Header="item" Binding="{Binding Name}" /> <DataGridTextColumn Header="subitems" Binding="{Binding ListSpecs[0]}" /> // first item of subcollection <DataGridTextColumn Header="subitems" Binding="{Binding ListSpecs[1]}" /> // second item of...

Datagrid shows only one record

c#,wpf,datagrid,wpfdatagrid

Set ItemsSource="{Binding}" for datagrid, and populate it with setting .DataContext = ObservableColelction, instead of setting ItemsSource

How to fill DataGrid in WPF using List?

c#,wpf,datagrid

Assuming each Object[] (in other words each row) consist of two strings then this is what you need: <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding YourList}"> <DataGrid.Columns> <DataGridTextColumn Header="Date" Binding="{Binding [0]}" /> <DataGridTextColumn Header="Time" Binding="{Binding [1]}" /> </DataGrid.Columns> </DataGrid> ...

Update DataGrid cell if other cell changes

c#,wpf,mvvm,datagrid

Solved it. I had to add a OnPropertyChanged("IdentificationCompanyType"); into the setter of the IdentificationCompanyType in the Identification class. After that it got automatically updated in the DataGrid....

.Net Reformat data in the List of List of Sting

c#,wpf,vb.net,xaml,datagrid

List<List<string>> lstStrings = new List<List<string>>{ new List<string>() {"A1","A2","A3"}, new List<string> {"B1","B2","B3"}, new List<string> {"C1","C2","C3"} }; List<List<string>> newList = new List<List<string>>(); int j=0; foreach(String s in lstStrings[0]) { List<string> innerList = new List<string>(); for(int i=0;i<lstStrings.Count;i++) { innerList.Add(lstStrings[i][j]); } j++; newList.Add(innerList); } foreach(List<string> lstInner in newList)...

WPF DatePicker DisplayDate binding does not work inside DataGrid/DataTemplate/ControlTemplate

wpf,datagrid,datepicker,datatemplate,controltemplate

https://connect.microsoft.com/VisualStudio/feedback/details/1291078 <DatePicker DisplayDate={Binding Path=DisplayDate} Loaded="DatePicker_Loaded" /> and add to the code: private void DatePicker_Loaded(object sender, RoutedEventArgs e) { DatePicker dp = sender as DatePicker; if (dp != null) { dp.ClearValue(DatePicker.DisplayDateProperty); } } ...

Laravel 5 / zofe/rapyd-laravel Datagrid : ErrorException in Factory.php line 150: array_merge(): Argument #2 is not an array

laravel,datagrid,array-merge

It's because you're passing your data in the wrong way to the view. Instead of return view('welcome',$grid); You should be doing: return view('welcome')->with('grid', $grid); or return view('welcome', ['grid' => $grid]); ...

Flex DataGrid Header Column Separator

flex,datagrid,flash-builder

Datagrid has two styles horizontalSeparatorSkin and verticalSeparatorSkin style which you can override. It seems you need to override the later. <mx:DataGrid id="grid" verticalGridLines="true" verticalSeparatorSkin="{VerticalSeparatorSkin}"> <mx:columns> <mx:DataGridColumn dataField="lbl" /> <mx:DataGridColumn dataField="val"/> </mx:columns> </mx:DataGrid> Now you can write this class as: public class VerticalSeparatorSkin extends ProgrammaticSkin { public function VerticalSeparatorSkin() { super();...

Datagrid not showing data in wpf with c#

c#,wpf,xaml,datagrid

Your code works fine with Loaded event but at the moment you set AutoGenerateColumns="False" and don't define columns. You need to either define columns manually <DataGrid AutoGenerateColumns="False" ... Loaded="dataGrid1_Loaded"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Name}" Header="Name"/> <DataGridTextColumn Binding="{Binding Value}" Header="Value"/> </DataGrid.Columns> </DataGrid> or let it auto generate columns <DataGrid AutoGenerateColumns="True" ... Loaded="dataGrid1_Loaded"/>...

Linq query to return country as column and cities as rows and count in cells

c#,sql,linq,binding,datagrid

If you want to create a "pivot table" from your database table to bind to a grid view, the easiest way I know of is to use a DataTable as the binding source and use a LINQ query to get the information to populate it. So we basically need to...

MVVM Light DataGrid binding

wpf,mvvm,data-binding,datagrid,mvvm-light

Try setting AutoGenerateColumns to False <DataGrid x:Name="LevelConfigurationDataGrid" AutoGenerateColumns="False" Grid.Column="1" Grid.Row="1" Margin="20,0" ItemsSource="{Binding LevelConfigs}"> <DataGrid.Columns> ... </DataGrid.Columns> </DataGrid> ...

Alter Display Text in Data Grid

c#,asp.net,datagrid

As @David suggested if you want relevant helpful answers post us compilable accurate code. This is just a guess based off how I format my DataRow output when I need it to be altered. Try to format the syntax before you do your table.Rows.Add() So instead of doing this foreach...

WPF DataGrid Binding to CurrentItem or SelectedItem?

wpf,data-binding,datagrid

Look at this: DataGrid CurrentItem != SelectedItem after reentry with tab-button First of all a row is selected by the user which makes the datagrid show that row in the selected way (SelectedItem and also CurrentItem contain the selected object). Then the focus is given to another control. In this...

Databinding a Datagrid

c#,wpf,data-binding,datagrid

You need to expose your ObservableCollection as a Property, not a Field. public class MainViewModel { public ObservableCollection<OptionStrike> oOs { get; set; } public MainViewModel() { oOs = new ObservableCollection<OptionStrike>(new OptionStrike[] { new OptionStrike("Put", 7500.00, 12345), new OptionStrike("Call", 7500.00, 123), new OptionStrike("Put", 8000.00, 23645), new OptionStrike("Call", 8000.00,99999) }); } }...

Visual Basic Datagrid View change row colour

vb.net,datagridview,datagrid

Is it possible that your datagridview isn't loaded fully when you try to recolor the rows? Since you are setting the datasource, you should put your code that affects the grid after you can make sure that it is finished loading. The column widths change because it is not dependent...

WPF DataGrid Does not show data when the ItemsSource is set

c#,wpf,datagrid

Please don't use WPF as if it were Windows Forms... it's not Windows Forms. In WPF, we use the DataGrid by loading data in a suitable form into a property and data bind that property to the DataGrid.ItemsSource property like this: <DataGrid ItemsSource="{Binding YourCollectionProperty}" ... /> ... // preferably implement...

WPF MVVM add row with two controls to Grid/DataGrid dynamically

c#,wpf,mvvm,datagrid

When i am binding a datagrid in wpf using mvvm rather than looking at it as a collection of rows and columns i see it as a collection of objects - each row represents an individual object, and each column represents a property of that object. So in your case,...

How to populate a DropDownList in a DataGrid?

c#,html,asp.net,drop-down-menu,datagrid

First of all add one hidden field control in data-grid for save the location Id of the row. After that when bind the drop-down you need to get the value from hidden field and set in drop-down as below. <asp:DataGrid runat="server" CssClass="tblResults" OnItemDataBound="dgList_ItemCreated" OnRowDataBound="OnRowDataBound" AllowSorting="true" OnSortCommand="dgTrailer_Sort" ID="dgTrailers" DataKeyField="ID" AutoGenerateColumns="false"> <HeaderStyle...

WPF: Programatically adding a ContextMenu to a DataGrid column header

c#,.net,wpf,datagrid,wpfdatagrid

DataGridColumns are not FrameworkElements so they do not have a ContextMenu. Since you want to do this all in code behind specifying a data template for the column can be a pain (IMHO). You could try passing in a FrameworkElement as the Header object for the column and set the...

WPF AutocompeteBox in datagrid Cell does not work properly

wpf,datagrid,autocomplete

Due to the way DataGridColumns are implemented, binding to parent viewmodels are always problematic. The reason you are getting the binding error is because the row is bound to Person, and Person does not have the Names property. The names property occur on MyViewModel and can be accessed like this...

c# changing background color of cell in dataGridView if its value changed

c#,datagrid,onchange

The DataGridViewCellEventArgs argument contains all you need here; private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "Version") { dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue; } } ...

Placing Hyperlinks in DataGrid

c#,html,asp.net,datagrid,datatable

row[3] = "<a href='" + row[3] + "/rev/" + row[1] + "'>" + "test" + "</a>"; I believe the colon after "href" is whats preventing you from clickable links. Change the colon to an "="...

Flex update dataprovider after datagrid edited

flex,datagrid,itemrenderer,dataprovider

Have not used Flex 3 since long but can you once check that whether ItemRenderer supports boolean property rendererIsEditor? If yes then set it to true then your renderer will also work as editor. EDIT: I tried your code now and there seems to be some compiler error with delcaration...

Extjs 4.2.2 - Default sorter logic runs instead of custom sorter

sorting,extjs,datagrid,extjs4.2

You should use the sortType configuration in your model's field definition, i.e. a function that returns the value used for sorting. Example configuration: fields: [ // ... other fields ... { name: 'AbsChange', sortType: function(value) { return Math.abs(value); } } ] ...

Can't add TemplateField to Datagrid

html,asp.net,visual-studio,drop-down-menu,datagrid

You should use TemplateColumn, when it comes to DataGrid as it is inherited from System.Web.UI.WebControls.DataGridColumn. TemplateField is inherited from System.Web.UI.WebControls.DataControlField, which make sense with GridView....

Binding DataGirdComboBoxColumn to DataSet doesn't work

wpf,datagrid,dataset

It seems like AirplaneID is readonly. Either make it writeable or change the binding to OneWay.

Variable Date Format for WPF DataGrid in C#

c#,wpf,datagrid

As Eugene mentioned, you'll want to use a converter. First, you'll want to add a class that implements IValueConverter: public class DateTimeFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var dateValue = value as DateTime?; if (dateValue != null) { var diff =...

WPF ListBox select next item after deletion with ICommand

wpf,xaml,mvvm,datagrid,listbox

Here's what I would do. Create a property in your ViewModel which will hold the SelectedItem. private YourTypeHere _SelectedThing; public YourTypeHere SelectedThing { get { return _SelectedThing; } set { _SelectedThing = value; //Call INotifyPropertyChanged stuff } } Now, bind your SelectedItem for your List to this property: <ListBox SelectedItem="{Binding...

Identify auto generated TextBox

c#,wpf,datagrid,textchanged

You can bind the PropertyGroup to the TextBox as Tag, then you can read it in the event handler and check the property group name: <DataGrid Name="propertyGrid"> <DataGrid.Columns> <DataGridTemplateColumn Header="Property Group Name"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding propertyGroupName}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn Header="Property 1">...

How to bind EF dataSet with WPF datagrid?

wpf,linq,entity-framework,datagrid,dataset

By default, the AutoGenerateColumns property of a DataGrid is true, which will cause it to append all of the columns to the end of whatever you've specified directly. Just set that to false and you should be good to go. <DataGrid Name="dataGridDomaines" Grid.Row="4" IsReadOnly="True" ItemsSource="{Binding}" AutoGenerateColumns="false"> <DataGrid.Columns> <DataGridTextColumn Header="Nom Domaine"...

Unexpected behavior of AlternativeRow BackColor in WPF

c#,wpf,datagrid,styles

Gabriel mentioned that this behavior is a known issue that raises when you try to create a brand-new style for data grid (or in general any item collection). I tried creating an style based on default style as suggested by Gabriel like following: <Style TargetType="{x:Type DataGrid}" BasedOn="{StaticResource {x:Type DataGrid}}"> <Setter...

Add three List to WPF datagrid

c#,wpf,datagrid

If they are all related, why are you even having three different lists? They should also live together. I mean create a class with all necessary properties. public class TemperatureEntity { public double Temperature {get; set;} public DateTime Time {get; set;} public string Rate{get; set;}//string or whatever type it is...

Checkbox column flickering when scrolling

wpf,vb.net,checkbox,datagrid

Well, the problem is, that the cells are rendered at the moment you scroll to them. First the checkbox appears, then the selection value. As described in smooth scrolling, you could try to set ScrollViewer.CanContentScroll=False which would draw your whole list at once (and deactivates the virtualization of the contents)...

KnockoutJS: working example for editable grid

knockout.js,datagrid

I would split the state-stuff you're adding using ko.extenders... the problem is that the editvalue observable doesn't initialize until you click the edit button so it doesn't work the first time you click it, but does work after that. In theory, everything you're trying to do should be done entirely...

Notify update of Tooltip Value (wpf)

wpf,xaml,binding,datagrid,notify

I would have done the converting from item to tooltip content in a dependency property in the item's datacontext. Therefore, when the process is finished you Raise property change of this "ToolTipContent" property, and thats it. In the property's Set you should create the content.

Bug in a Scroll of DataGrid - WPF?

wpf,scroll,datagrid

It is probably just recycling for speed Try VirtualizingStackPanel.VirtualizationMode="Standard"...

How do I highlight a row in the WPF DataGrid when SelectionMode is set to Cell

c#,wpf,datagrid

I've played a bit here, nothing spectacular but is a working version: <Style TargetType="DataGridCell"> <EventSetter Event="Selected" Handler="EventSetter_OnHandlerSelected"/> <EventSetter Event="LostFocus" Handler="EventSetter_OnHandlerLostFocus"/> </Style> This is the codebehind: private void EventSetter_OnHandlerSelected(object sender, RoutedEventArgs e) { DataGridRow dgr = FindParent<DataGridRow>(sender as DataGridCell); dgr.Background = new SolidColorBrush(Colors.Red); } private void...

Reset DataGrid.SelectedIndex after user has selected another

c#,wpf,datagrid,wpfdatagrid

Try setting the SelectedItem property. Preserve what was selected before and set the SelectedItem with what was previously selected in your event. Something like this: private void DgDataGrid_OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) { int newIndex = (sender as DataGrid).SelectedIndex / 2; if (Convert.ToInt32(newIndex) >= 1) (sender as DataGrid).SelectedItem = previous; else...

How to change/prepopulate SelectedIndex for each individual Combobox in DataGridTemplate?

c#,wpf,xaml,datagrid,combobox

It'd be easy if you create a Customer ViewModel class with Name and Location property and create an ObservableCollection<Customer> customersand set that as the ItemsSource for the datagrid and use it to bind the columns. public class Customer { public string Name {get; set;} public string Location {get; set;} }...

How to filter Datagrid using DateTime Picker?

vb.net,datagridview,datagrid,datepicker

Take a look at the DataView.RowFilter property. This allows you to filter data in your DataGridView, using expressions. ' Set the data source. MyDataGridView.DataSource = myDataTable ' Set the filter. DirectCast(MyDataGridView.DataSource, DataTable).DefaultView.RowFilter = String.Format("DateColumn = '{0:yyyy-MM-dd}'", MyDateTimePicker.Value) ...

How to edit HeaderText for TemplateColumn inside DataGrid

c#,asp.net,sql-server,datagrid

After working on this for a while more I was finally able to complete the changes necessary. OnItemDataBound worked for me, allowing me to make the changes while the data was in the process of binding. Each case had to be checked so the label would correctly display the information...

How to update Datagrid with an ItemsSource that doesn't know when an item is added?

c#,wpf,data-binding,datagrid

You shouldn't bind the UI to a property in the view model that always gives a new value. This is why your original version works. Adding and removing items from the observable collection should update the UI as it implements INotifyCollectionChanged. So keep a single observable collection, bind it to...

Datagrid show empty lines even that the datagrid keeps the values

c#,wpf,datagrid

It's important that all the members you show are public, if not they won't be visible in the grid. Try creating a public get method to your properties if you don't have one. EDIT: <DataGrid Name="DataGrid1" AutoGenerateColumns="False" "> <DataGrid.Columns> <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" Width="*"/> </DataGrid.Columns> </DataGrid> Public class Person {...

How to hide left part instead of right part of a WPF datagrid column when resize it?

wpf,datagrid,resize,datagridtextcolumn

Turn out it is quite easy: <DataGridTextColumn Header="URL" Binding="{Binding Path=url}"> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="HorizontalAlignment" Value="Right"/> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> ...

DataGrid Multiplicating Two Columns

c#,wpf,datagrid

You dont need to use a converter for doing this calculation. Hope you can handle it in Model Class. Also You need to bind to property. DataGrid binding property Names are not correct c# is case sensitive. Refer my below code. <DataGrid x:Name="dgr" AutoGenerateColumns="False" ItemsSource="{Binding LoadDataBinding}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Path=PrecioGram,...

Unable to get code behind event to fire

asp.net,vb.net,datagrid

You need to handle the ItemCommand event. Change OnSelectedIndexChanged="EditItem" to OnEditCommand="EditItem". Or you could just remove it from markup and add a handles clause like below: Protected Sub EditItem(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgrdItem.ItemCommand If e.CommandName = "Edit" ... End Sub ...

GWT FlowPanel not adding widget

css,gwt,datagrid,flowpanel

You tell DataGrid to take all available space inside the FlowPanel. Then you tell Grid widget to do the same. The result is that your Grid has a height of zero, since there was no space left for it after the DataGrid took 100% of the FlowPanel height. You either...

How to bind a datagrid row with text boxes in wpf mvvm

wpf,mvvm,binding,datagrid

Welcome to StackOverflow! Usually people won't answer questions without the following. A clear summary of what you're attempting to do. All of the relevant code Any exceptions that you are experiencing All of the research links you used in order to get where you are That said, I will give...

How to mark a multiple selection on a DataGrid control?

c#-4.0,datagrid

Just revisited the code and found that I was not updating the SelectedItems IList: Dispatcher.BeginInvoke(new Action(delegate { foreach (var item in e.RemovedItems) { SelectedItems.Add(item); } SelectedItemsList.Add(SelectedItem); }), System.Windows.Threading.DispatcherPriority.ContextIdle, null); ...

Datagrid inside a Custom control is not updating

c#,wpf,xaml,datagrid

One minor mistake made by you in CustonDatagrid.xaml <DataGrid ItemsSource="{Binding ElementName=CustonDataGrid, Path=Colection}" DockPanel.Dock="Top"></DataGrid> There is no element called CustonDataGrid because of which the elements were never reflected. Changed it to <DataGrid ItemsSource="{Binding Path=Colection}"></DataGrid> I also made minor change in your MainWindow.cs public partial class MainWindow : Window { public MainWindow()...

How do I delete selected grid row programmatically

c#,wpf,datagrid

You need to remove element from your data source, which is in this case DataTable dt. Just use the following code to remove selected row from the table: private void DeleteRow(object sender, RoutedEventArgs e) { dt.Rows.RemoveAt(DataGrid1.SelectedIndex); } ...

WPF DataGrid: Displaying 2 decimal places when not editing, but full number when editing

c#,wpf,datagrid,wpfdatagrid

You need to take away the string format at the parent level (which is overriding the EditingElementStyle) - and instead set the string format for the binding expression only in the styles for EditingElementStyle - but also for the regular ElementStyle (non-editing mode) which is a TextBlock style: <DataGridTextColumn Header="s"...

Insert a blank row into a Datagrid with dynamic columns

c#,silverlight,datagrid

Okey, let me clear up some confusion before we proceed: Since the columns are dynamic and are only known in runtime, I need to create an entity whose attributes can be set in run time. Not necessarily, you can use a list of objects. I thought of converting my ProdCatList...

WPF DataGrid Trigger on cell content

c#,wpf,datagrid,triggers

You can't access DataGridCell.Content that way, use a DataTrigger instead based on your DataGrid.SelectedItem.YourProperty like this: <DataGrid.CellStyle> <Style TargetType="DataGridCell"> <Setter Property="FontWeight" Value="Bold" /> <Style.Triggers> <DataTrigger Binding="{Binding YourProperty}" Value="0"> <Setter Property="FontWeight" Value="Normal"/> </DataTrigger> </Style.Triggers> </Style> </DataGrid.CellStyle> EDIT: Assuming your DataGridColumns are text-based then you can...

ItemContainerGenerator.Items in .NET 4.0

c#,.net,wpf,datagrid,itemcontainergenerator

The ItemContainerGenerator.Items seems to be present in .NET 4.0: https://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid_properties(v=vs.100).aspx .NET Framework 4 Other Versions ... ItemContainerGenerator Gets the ItemContainerGenerator that is associated with the control. (Inherited from ItemsControl.) ...

WPF Binding DataGrid Not Updating

c#,wpf,datagrid

i would change your code to <Grid Margin="10"> <DataGrid ItemsSource="{Binding EntityList}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="Id" Binding="{Binding Id}" /> <DataGridTextColumn Header="Last Name" Binding="{Binding LastName}" /> <DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" /> <DataGridTextColumn Header="Middle Name" Binding="{Binding MiddleName}" /> <DataGridCheckBoxColumn Header="Status" Binding="{Binding StatusId}" />...

Wpf-Datagrid and ObservableCollection-AutoGenerateColumns?

c#,wpf,datagrid

Your class should contain Properties, not Variables. The DataGrid will only look for public properties instead of public variables. See here, and here...

Implementing datagrid gem & session helper methods

ruby-on-rails,ruby,ruby-on-rails-4,datagrid

This DataGrid seems to be set up more or less like a Model class, and I think that's an important hint that they're serious about object orientation and encapsulation: the innards of the class won't automatically have access to the outside world, you need to manually specify the info you...

Variable in stackpanel inside of DataGrid-RowDetailsTemplate is not recognize

c#,wpf,datagrid,rowdetailstemplate

Assuming you name your DataGrid dataGrid, then this is what you need: private void check_Click(object sender, RoutedEventArgs e) { DataGridRow dgRow = (DataGridRow)(dataGrid.ItemContainerGenerator.ContainerFromItem(dataGrid.SelectedItem)); if (dgRow == null) return; DataGridDetailsPresenter dgdPresenter = FindVisualChild<DataGridDetailsPresenter>(dgRow); DataTemplate template = dgdPresenter.ContentTemplate; TextBox textBox = (TextBox)template.FindName("toCheck", dgdPresenter); string needCheck = textBox.Text; if (needCheck == "abc") {...

Filling Datagrid with DataTable wpf

c#,wpf,datagrid

First of all, you should consider using WPF with at least a bit of MVVM pattern. It means you're gonna provide DataContext class for your View (V) called ViewModel(VM). We're gonna move all the data we will later on bind controls to there. ViewModel: public class ViewModel { public DataTable...

C# XAML - How to add a combobox to some datagrid ROWS but not others?

c#,wpf,xaml,datagrid,combobox

Try using a DataTrigger with predefined DataTemplate items: <DataTemplate x:Key="OneItem" DataType="{x:Type ValueItem}" > <TextBox Text="{TemplateBinding Id}" /> </DataTemplate> <DataTemplate x:Key="MultiItems" DataType="{x:Type ValueItem}" > <ComboBox ItemsSource="{TemplateBinding ValueItems}" DisplayMemberPath="ValueName" SelectedValuePath="ID" SelectedValue="{TemplateBinding Id}" /> </DataTemplate> And then use a Content control to place the style accordingly. I haven't tried this but your data...

RowAction in a Vector source APYDataGridBundle Symfony 2

symfony2,vector,datagrid,doctrine2

I ended up using an Entity source instead of a Vector, and because the data was from a stored procedure/native query, it was imposible for doctrine to find me the current row with the id, so my client ended up creating a new stored procedure that uses the row id...

WPF boolean column checkbox

c#,wpf,checkbox,datagrid

Xaml: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:local="clr-namespace:WpfApplication1" > <Window.DataContext> <local:MyViewModel/> </Window.DataContext> <Window.Resources> <local:BooleanToTextConverter x:Key="booleanToTextConverter" /> <local:BoolToColorConverter x:Key="booleanToColorConverter" />...