Search Results

Search found 1114 results on 45 pages for 'datagrid'.

Page 4/45 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • WPF DataGrid: How to set content alignment of RowHeader to 'Center'

    - by Nike
    I use WPF DataGrid. I put a text value in RowHeader and want to set alignment of RowHeader content to 'Center'. I tried this: <toolkit:DataGrid.RowHeaderStyle> <Style TargetType="{x:Type toolkit:Primitives.DataGridRowHeader}"> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> </Style> </toolkit:DataGrid.RowHeaderStyle> but it doesn't work. Actually I think that there is TextBlock in RowHeader and I need to set its TextAlignment Property to Center. How can do it?

    Read the article

  • WPF - Weird results with DataGrid - extra line for editing entries

    - by Jim Beam
    Working with WPF and C#. I have a page with a datagrid that lists a series of objects with List as the DataContext. I recently had it working in the code behind and the Datagrid would show the extra line at the bottom of the datagrid for new entries. Now, I have moved the exact same code to its own library project. The data still appears but the extra line for entry does not and users cannot add a new record. I have already tried using grid.CanUserAddNew = true; but that does not solve it. So, it must be something in the List object - it's the exact same code as before, only pulling from a library. Help.

    Read the article

  • Merge DataGrid ColumnHeaders

    - by Vishal
    I would like to merge two column-Headers. Before you go and mark this question as duplicate please read further. I don't want a super-Header. I just want to merge two column-headers. Take a look at image below: Can you see two columns with headers Mobile Number 1 and Mobile Number 2? I want to show there only 1 column header as Mobile Numbers. Here is the XAML used for creating above mentioned dataGrid: <DataGrid Grid.Row="1" Margin="0,10,0,0" ItemsSource="{Binding Ledgers}" IsReadOnly="True" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="Customer Name" Binding="{Binding LedgerName}" /> <DataGridTextColumn Header="City" Binding="{Binding City}" /> <DataGridTextColumn Header="Mobile Number 1" Binding="{Binding MobileNo1}" /> <DataGridTextColumn Header="Mobile Number 2" Binding="{Binding MobileNo2}" /> <DataGridTextColumn Header="Opening Balance" Binding="{Binding OpeningBalance}" /> </DataGrid.Columns> </DataGrid> Update1: Update2 I have created a converter as follows: public class MobileNumberFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null && value != DependencyProperty.UnsetValue) { if (value.ToString().Length <= 15) { int spacesToAdd = 15 - value.ToString().Length; string s = value.ToString().PadRight(value.ToString().Length + spacesToAdd); return s; } return value.ToString().Substring(0, value.ToString().Length - 3) + "..."; } return ""; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } I have used it in XAML as follows: <DataGridTextColumn Header="Mobile Numbers"> <DataGridTextColumn.Binding> <MultiBinding StringFormat=" {0} {1}"> <Binding Path="MobileNo1" Converter="{StaticResource mobileNumberFormatConverter}"/> <Binding Path="MobileNo2" Converter="{StaticResource mobileNumberFormatConverter}"/> </MultiBinding> </DataGridTextColumn.Binding> </DataGridTextColumn> The output I got: Update3: At last I got the desired output. Here is the code for Converter: public class MobileNumberFormatConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value != null && value != DependencyProperty.UnsetValue) { if (parameter.ToString().ToUpper() == "N") { if (value.ToString().Length <= 15) { return value.ToString(); } else { return value.ToString().Substring(0, 12); } } else if (parameter.ToString().ToUpper() == "S") { if (value.ToString().Length <= 15) { int spacesToAdd = 15 - value.ToString().Length; string spaces = ""; return spaces.PadRight(spacesToAdd); } else { return "..."; } } } return ""; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } Here is my XAML: <DataGridTemplateColumn Header="Mobile Numbers"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock> <Run Text="{Binding MobileNo1, Converter={StaticResource mobileNumberFormatConverter}, ConverterParameter=N}" /> <Run Text="{Binding MobileNo1, Converter={StaticResource mobileNumberFormatConverter}, ConverterParameter=S}" FontFamily="Consolas"/> <Run Text=" " FontFamily="Consolas"/> <Run Text="{Binding MobileNo2, Converter={StaticResource mobileNumberFormatConverter}, ConverterParameter=N}" /> <Run Text="{Binding MobileNo2, Converter={StaticResource mobileNumberFormatConverter}, ConverterParameter=S}" FontFamily="Consolas"/> </TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> Output:

    Read the article

  • Binding WPF DataGrid to DataTable using TemplateColumns

    - by Chris J
    I have tried everything and got nowhere so I'm hoping someone can give me the aha moment. I simply cannot get the binding to pull the data in the datagrid successfully. I have a DataTable that contains multiple columns with of MyDataType} public class MyData { string nameData {get;set;} boolean showData {get;set;} } MyDataType has 2 properties (A string, a boolean) I have created a test DataTable DataTable GetDummyData() { DataTable dt = new DataTable("Foo"); dt.Columns.Add(new DataColumn("AnotherColumn", typeof(MyData))); dt.Rows.Add(new MyData("Row1C1", true)); dt.Rows.Add(new MyData("Row2C1", false)); dt.AcceptChanges(); return dt; } I have a WPF DataGrid which I want to show my DataTable. But all I want to do is to change how each cell is rendered to show [TextBlock][Button] per cell with values bound to the MyData object and this is where I'm having a tonne of trouble. My XAML looks like this <Window.Resources><ResourceDictionary><DataTemplate x:Key="MyDataTemplate" DataType="MyData"> <StackPanel Orientation="Horizontal" > <Button Background="Green" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,0,0" Content="{Binding Path=nameData}"></Button> <TextBlock Background="Green" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0,0,0" Text="{Binding Path=nameData}"></TextBlock> </StackPanel> </DataTemplate></ResourceDictionary></Window.Resources> <Grid> <dg:DataGrid Grid.Row="1" AutoGenerateColumns="True" x:Name="dataGrid1" SelectionMode="Single" CanUserAddRows="False" CanUserSortColumns="true" CanUserDeleteRows="False" AlternatingRowBackground="AliceBlue" AutoGeneratingColumn="dataGrid1_AutoGeneratingColumn" ItemsSource="{Binding}" /> now all I do once loaded is to attempt to bind the DataTable to the WPF DataGrid dt = GetDummyData(); dataGrid1.ItemsSource = dt.DefaultView; The TextBlock and Button show up, but they don't bind, which leaves them blank. Could anyone let me know if they have any idea how to fix this. This should be simple, thats what Microsoft leads us to believe. I have set the Column.CellTemplate during the AutoGenerating event and still get no binding. Please help!!!

    Read the article

  • Get content of a single cell from a DataGrid in Flex 3

    - by Captain Phoenix
    I want to select information in a single cell from my DataGrid in Flex 3. Specifically, I'm displaying three phone numbers per line and the user needs to be able to select one of those numbers, from any row, but not the whole row. While similar to this, I am displaying the DataGrid to the user. The answer for that question was to manipulate the dataProvider, how can I know what cell I've selected in order to do that?

    Read the article

  • Access Controls in Silverlight DataGrid Column Header from Code

    - by fuzzyman
    We have custom headers in the Silverlight DataGrid using the ContentTemplate. We've got a button in the header and need to programmatically access the button to hook up the event. We're using IronPython, so we can't statically bind the event in the xaml (plus we use the grid for many different views - so we dynamically generate the xaml). How can we get access to controls inside a datagrid column header?

    Read the article

  • Silverlight DataGrid Updating SelectedItem from code

    - by Mark Cooper
    When I update a datagrid SelectedItem from code (via a bound object in a ViewModel), how to I get the visual grid to highlight the newly selected item? Thanks, Mark UPDATE: This is still an issue for me. My SelectedItem property already implements change notification, but the datagrid is not VISUALLY displaying which row has been selected - i.e. it is not getting highlighted.

    Read the article

  • "freeze" one column in flex datagrid

    - by Bob Spidell
    I'm using a datagrid to display a column of date ranges and several columns of data. I'd like to make the first column (the date ranges) fixed; i.e. that column stays in place when the user scrolls the other columns. That way, the dates column will always be visible as the user scrolls through many data columns. I don't see a datagrid property for this; anyone have a solution? TIA

    Read the article

  • Attach a div to Dojo DataGrid horizontal scroll

    - by Kevin
    I have a fixed width datagrid being built programatically, and am trying to put a header over top of it that will scroll with it. I can't do it as part of the grid as that destroys the fixed width of the cells. I would like to be able to scroll the top div as the scrollbar for the DataGrid scrolls. This seems how the header works already, so it should be possible. I just can't figure out how to link/attach it.

    Read the article

  • Silverlight DataGrid Exception Reordering Column Headers

    - by Mike
    I'm trying to set the initial display order of the column headers in a silverlight datagrid by changing the column header DisplayIndex values. If I try to set the column order at page load time, I get an out of range exception. If I set the column order (same routine) at a later time like, in a button click handler, it works. Is this just a bug in the silverlight datagrid control? Suggestions for a possible work around?

    Read the article

  • Silverlight3 bind checkbox list to a datagrid

    - by Stester
    I have a enum, like public enum TestType { Red = 1, Blue = 2, Green = 3, Black = 4 } I want to attach those values to a datagrid as checkboxes in silverlight 3. (I would like to bind to a listview, but its not exists in silverlight) Manage to get the enums to a ObservableCollection, any help to bind to datagrid? I tried with ItemsSource="{Binding Path=nameOfTheObservableCollection, }"

    Read the article

  • Store columns order from WPF DataGrid.

    - by Polaris
    I developing WPF Application. Also I use WPF DataGrid in my app. I store columns visibility in XML file like I want also to store columns order in the same file like How can I do this? Or Maybe you have your technics how to store order for WPF DataGrid. Thank for help.

    Read the article

  • Flex DataGrid not Displaying Data

    - by asawilliams
    I have a custom dataGrid that acts more like a 2D list (if that makes sense at all). I am dynamically creating the columns and recreating the dataProvider to suit my needs. While debugging I can see that I am creating the columns and setting them to the dataGrid and creating and setting the dataProvider, but for some reason I am able to see the dataGrid and the columns but not the data. [Bindable] private var mockData:ArrayCollection = new ArrayCollection([ {value: "425341*"}, {value: "425341*"}, {value: "425341*"}, {value: "425341*"}, {value: "425341*"}, {value: "425341*"}, {value: "425341*"}, {value: "425341*"}, {value: "425341*"}]); ... <TwoDimensionalList width="100%" height="100%" numColumns="7" numRows="7" dataField="value" dataProvider="{mockData}"/> The snippet of code from the object only contains the important functions, everything else is not important (getters, setters, etc ...). While debugging I checked all the variables in the functions to make sure they were assigned and a value that I was expecting. [Snippet] public class TwoDimensionalList extends DataGrid { ... /** * Creates and sets properties of columns */ private function createColumns():void { var column:DataGridColumn; var cols:Array = this.columns; for(var i:uint=0; i < numColumns; i++) { column = new DataGridColumn("column"+i.toString()); column.dataField = "column"+i.toString(); cols[i]=column; } this.columns = cols; // go to the current gotoPage(this._currentPageNum); } /** * Sets the data for the dataprovider based on the * number of columns, rows, and page number. * * @param pageNum the page number of the data to be viewed in the DataGrids. */ private function gotoPage(pageNum:uint):void { _currentPageNum = pageNum; var startIndex:uint = (pageNum-1)*numColumns*numRows; var data:ArrayCollection = new ArrayCollection(); for(var i:uint=0; i < numRows; i++) { var obj:Object = new Object(); for(var j:uint=0; j < numColumns; j++) { if((i+(j*numRows)+startIndex) < _dataProvider.length) obj["column"+j.toString()] = String(_dataProvider.getItemAt(i+(j*numRows)+startIndex)["value"]); } data.addItem(obj); } this.dataProvider = data; } }

    Read the article

  • WPF DataGrid Get All SelectedRows

    - by anvarbek raupov
    Have to use free WPF DataGrid (I thought Infragistics libraries are bad, I take it back after this) for this project of mine. Looks like DataGrid doesnt have clean MVVM Friendly way of getting the list of selectedRows ? I can data bind to SelectedItem="{Binding SelectedSourceFile}" but this only shows the 1st selected row. Need to be able to get all selected rows. Any hints to do it cleanly via MVVM ?

    Read the article

  • Weird Datagrid / paint behaviour

    - by Shane.C
    The scenario: A method sends out a broadcast packet, and returned packets that are validated are deemed okay to be added as a row in my datagrid (The returned packets are from devices i want to add into my program). So for each packet returned, containing information about a device, i create a new row. This is done by first sending packets out, creating rows and adding them to a list of rows that are to be added, and then after 5 seconds (In which case all packets would have returned by then) i add the rows. Here's a few snippets of code. Here for each returned packet, i create a row and add it to a list; DataRow row = DGSource.NewRow(); row["Name"] = deviceName; row["Model"] = deviceModel; row["Location"] = deviceLocation; row["IP"] = finishedIP; row["MAC"] = finishedMac; row["Subnet"] = finishedSubnet; row["Gateway"] = finishedGateway; rowsToAdd.Add(row); Then when the timer elapses; void timerToAddRows_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { timerToAddRows.Enabled = false; try { int count = 0; foreach (DataRow rowToAdd in rowsToAdd) { DGSource.Rows.Add(rowToAdd); count++; } rowsToAdd.Clear(); DGAutoDevices.InvokeEx(f => DGAutoDevices.Refresh()); lblNumberFound.InvokeEx(f => lblNumberFound.Text = count + " new devices found."); } catch { } } So at this point, each row has been added, and i call the re paint, by doing refresh. (Note: i've also tried refreshing the form itself, no avail). However, when the datagrid shows the rows, the scroll bar / datagrid seems to have weird behavour..for example i can't highlight anything with clicks (It's set to full row selection), and the scroll bar looks like so; Calling refresh doesn't work, although if i resize the window even 1 pixel, or minimize and maximise, the problem is solved. Other things to note : The method that get's the packets and adds the rows to the list, and then from the list to the datagrid runs in it's own thread. Any ideas as to something i might be missing here?

    Read the article

  • How do I use a DataGrid to display the contents of a MDB

    - by orangecl4now
    I'm relatively new to .Net 4 and I am creating my FIRST WPF application using a MDB as a backend datasource. I designed my UI. I have a TextField (called Name), a Combobox (called Division) and a DataGrid (called dataGrid1). The only problem I'm having is figuring out how to link my DataGrid to display data from the DataSource. and load the data in the Windows1_Loaded method. Thanks

    Read the article

  • Inject Rows into Silverlight DataGrid

    - by Stephan
    Does anyone know of a way to inject rows into a Silverlight DataGrid? I need a way to add totals rows after every 6 entries. The totals are for all rows above the summary row, not just the previous six. I've tried doing it with grouping but that only shows the totals for the group and displays the totals rows above the actual rows. I would prefer to use a DataGrid for this if possible, but all solutions are welcome.

    Read the article

  • Get Row of DataGrid in User Control Page

    - by Romil
    My Question is related to access the rows in one page and putting conditions in another page. I need to check whether a datagrid has row in it or not. DataGrid is in .aspx page. Based on this checking i need to write a condition in .ascx page. the .ascx on which condition is checked is linked to .aspx page. Meaning that UserControl1.ascx is Register with Default.aspx page I am using VS 2003 Please advice Thanks

    Read the article

  • Dojo Datagrid Filtering Issue

    - by Zoom Pat
    I am having hard time filtering a datagrid. Please help! This is how I draw a grid. var jsonStore = new dojo.data.ItemFileWriteStore({data:columnValues}); gridInfo = { store: jsonStore, queryOptions: {ignoreCase: true}, structure: layout }; grid = new dojox.grid.DataGrid(gridInfo, "gridNode"); grid.startup(); Now if i try something like this, it works fine and gives me the rows which has the column (AGE_FROM) value equal to 63. grid.filter({AGE_FROM:63}); but I need all kinds of filtering and not just 'equal to' So how do I try to obtain all the rows which have AGE_FROM 63, and < 63 and <= 63 and =63. because grid.filter({AGE_FROM:<63}); does not work Also One other way I was thingking was to use the following filteredStore = new dojox.jsonPath.query(filterData,"[?(@.AGE_FROM = 63]"); and then draw the grid with the filteredStore, but the above is not working for a != operator. Once I figure a good way to filter grid I need to see a way to filter out dates. I am trying to find a good example for filtering dataGrid but most of the examples are just filtering based on the 'equal to' criteria. Any help is highly appreciated.

    Read the article

  • Silverlight 3 - How to "refresh" a DataGrid content?

    - by Josimari Martarelli
    I have the following scenery: 1 using System; 2 using System.Windows; 3 using System.Windows.Controls; 4 using System.Windows.Documents; 5 using System.Windows.Ink; 6 using System.Windows.Input; 7 using System.Windows.Media; 8 using System.Windows.Media.Animation; 9 using System.Windows.Shapes; 10 using System.Collections.Generic; 11 12 namespace refresh 13 { 14 public partial class MainPage : UserControl 15 { 16 17 List c = new List(); 18 19 public MainPage() 20 { 21 // Required to initialize variables 22 InitializeComponent(); 23 c.Add(new Customer{ _nome = "Josimari", _idade = "29"}); 24 c.Add(new Customer{_nome = "Wesley", _idade = "26"}); 25 c.Add(new Customer{_nome = "Renato",_idade = "31"}); 26 27 this.dtGrid.ItemsSource = c; 28 } 29 30 private void Button_Click(object sender, System.Windows.RoutedEventArgs e) 31 { 32 c.Add(new Customer{_nome = "Maiara",_idade = "18"}); 33 } 34 35 } 36 37 public class Customer 38 { 39 public string _nome{get; set;} 40 public string _idade{get; set;} 41 } 42 } Where, dtGrid is my DataGrid control... The Question is: How to get the UI Updated after adding one more register to my list. I get to solve it setting the DataGrid's Item Source to "" and then setting to the list of Customer objects again, like that: 1 private void Button_Click(object sender, System.Windows.RoutedEventArgs e) 2 3 { 4 5 c.Add(new Customer{_nome = "Maiara",_idade = "18"}); 6 7 this.dtGrid.ItemsSource=""; 8 9 this.dtGrid.ItemsSource=c; 10 11 } 12 Is there a way to get the UI updated or the datagrid's itemsSource refreshed automatically after updating, altering or deleting an item from the list c ? Thank you, Josimari Martarelli

    Read the article

  • wpf datagrid extra column in header on left

    - by sb
    I keep getting this button in the header, I can click on the button to select all rows. This misaligns the data from the header. Any ideas? Thanks in Advance. Datagrid image via link: http://picasaweb.google.com/lh/photo/CahvlINknhL5ykIW2zCfIw?feat=directlink <dg:DataGrid.Columns> <dg:DataGridTextColumn Header="Description" Width=".5*" Binding="{Binding Description}"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Type" Width="100" Binding="{Binding Type}"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Amount $" Width="100" Binding="{Binding Amount}"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Effective From Date" Width="100" Binding="{Binding EffectiveFromDate}" IsReadOnly="True"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Effective To Date" Width="100" Binding="{Binding EffectiveToDate}" IsReadOnly="True"> </dg:DataGridTextColumn> <dg:DataGridTextColumn Header="Status" Width="100" Binding="{Binding Status}"> </dg:DataGridTextColumn> </dg:DataGrid.Columns>

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >