Now I've a problem , because I want to create a number of pages that I want populate with a Grid and into the Grid. I want to create a series of Button.
How can I create a Grid into a Page?
I'm tried with following code:
SortedList<string, Page> pageList = new SortedList<string, Page>();
for (int i = 0; i < 3; i++)
{
pageList.Add(string.Format("Page{0}", i), new Page());
}
Grid LayoutRoot = new Grid(); // ???????
What I can do to insert a Grid into a Page? I want that refer to Grid for example:
pageList["Page2"].LayoutRoot;
Thanks.
Related
I created datatable and fill it with columns and rows then i "add" this datatable to datagrid and my question is:
How to hide one row? In datatable or datagrid it doesnt matter for me. Its possible to do that?
In Windows Forms was something like CurrencyManager and that do all the job.
Okay, I found a wayto hide rows:
for (int i = 0; i < dataGrid.Items.Count; i++)
{
DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator
.ContainerFromIndex(i);
Console.WriteLine(row.GetIndex());
// Console.WriteLine(row.Item);
Console.WriteLine((row.Item as DataRowView).Row.ItemArray[3].ToString());
string plec = (row.Item as DataRowView).Row.ItemArray[3].ToString();
if (plec == "M")
{
row.Focus();
row.Visibility = System.Windows.Visibility.Collapsed;
}
}
But when rows are Collapsed after click on column header to asceding or descending my datagrid show all rows(collapsed rows too).
How to block this and use filter only on visble rows?
In my application there are two panels -A and B.
I am using "border" layout, the panel A is in center region and panel B is in south region which have height 200.
The "panel A" have lot of items like grid, toolbar etc. also "panel B" have some items.
My question is, How can I exchange the contents of A to B and B to A.
Note: I am using "Extjs 3.2"
Regards,
Mohammed Shafeek
Panels in center and south region of border layout have to be wrapped by container component. Then you can easily get content of each container, clear the container and add to it content from second container.
So function for switch panels should looks like this:
function switchPanels() {
southContainer = Ext.getCmp('southContainer');
centerContainer = Ext.getCmp('centerContainer');
southContainerItems = southContainer.items.getRange();
centerContainerItems = centerContainer.items.getRange();
southContainer.removeAll(false);
centerContainer.removeAll(false);
for (var i = 0; i < southContainerItems.length; i++) {
centerContainer.add(southContainerItems[i]);
};
for (var i = 0; i < centerContainerItems.length; i++) {
southContainer.add(centerContainerItems[i]);
};
centerContainer.doLayout();
southContainer.doLayout();
}
For complete live example look at this fiddle: https://fiddle.sencha.com/#fiddle/2iv
I am using Synfusion's Data Bound Grid.
I have set two properties as
this.mygrid.TableModel.Options.EnterKeyBehavior = GridDirectionType.Right;
this.mygrid.TableModel.Options.WrapCellBehavior = GridWrapCellBehavior.WrapGrid;
If no column is hidden this works fine. If i hide any column then it doesn't works.
Please help me to achieve enter key behaviour if columns are hidden.
Thanks in Advance
I have handled the following code for hiding columns :
GridColHidden[] hiddenCols = new GridColHidden[ 3];
for (int i = 0; i < 3; i++)
{
hiddenCols[i] = new GridColHidden(i + 1);
}
this.gridDataBoundGrid1.Model.ColHiddenEntries.AddRange(hiddenCols);
I have now added the following code.
this.mygrid.TableModel.Options.EnterKeyBehavior = GridDirectionType.Right;
this.mygrid.TableModel.Options.WrapCellBehavior = GridWrapCellBehavior.WrapGrid;
I was able to see the first cell is set as current cell , when Enter key is pressed with the current cell's position placed in last cell in Grid.
I am developing an application in WPF, and a part of the application involves pulling and merging data frfom three excel sheets and displaying in datagrid. Now if a row in datagrid has a queue that corresponds to more than one application , then it will display a combobox , whoseitems will be pulled from another excel sheets by looking up the correspoding queue name in that excel sheet.
I had before used the same functionality in ASP.NET and achieved quite easily , using the following code :
for (int i = 0; i < dt.Rows.Count; i++)
{
//Filling datatable dsq from excel sheet
//dsq contains the data where it is found out how many applications are there for
//ith row in Gridview
count[i] = dsq.Tables[0].Rows.Count;
foreach (GridViewRow row in gvApplications.Rows)
{
// Transferring gridview rows to a datatable
if (row.Cells[0].Text.Trim().Equals(dt.Rows[i][0].ToString().Trim()))
{
//Dropdownlist is added only when no. of applications for each queue , i.e. ,
/count[i] is greater than 1 , else level control is added.
if (count[i] > 1)
{
DropDownList drp = new DropDownList();
drp.DataSource = dsq.Tables[0];
drp.DataTextField = "Application Name";
drp.DataValueField = "Application Name";
drp.DataBind();
row.Cells[7].Controls.Add(drp);
}
}
else
{
Label l = new Label();
l.Text = dsq.Tables[0].Rows[0][0].ToString().Trim();
l.ID = "label" + row.RowIndex.ToString();
row.Cells[7].Controls.Add(l);
}
}
Now I want the same functionality in WPf. Kindly help me out.
You can use a DataGridTemplateColumn inside that you can put a ContentControl with DataTemplateSelector.
I have problem related to datagridview in Winform.
I have a list of table names in my left panel. When I click on Table I show the table content in right panel. I am showing data in a datagridview by fetching data and assigning datasource to dgv.
I am setting following property to dgv.
dgTemp.Dock = DockStyle.Fill;
dgTemp.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
dgTemp.AutoSize = true;
dgTemp.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dgTemp.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgTemp.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
dgTemp.ReadOnly = true;
dgTemp.AutoGenerateColumns = true;
dgTemp.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgTemp.AllowUserToAddRows = false;
My problem is there can be any number of columns in Datasource I am assigning to dgv. So if there are very few number of columns (say 1 or 2) the dgv size stands very small and the empty space on right side give very ugly look.
I can't use auto autosizecolumnmode to fill since when there is more columns all columns get shrink and expanding columns dont give me Scroll at bottom
so My requirement is
All space in datagridview should be filled. (should cover all area)
When there is more column, there should appear scroll, so it give better look
are there any events or properties which I can use ??
Thanks in anticipation.
Try this :
dgTemp.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
Update :
dataGridView1.FirstDisplayedScrollingRowIndex = 5; //use 5 because you want to start from 5
//you can have a horizontal scroll bar with this code :
dataGridView1.FirstDisplayedScrollingColumnIndex = 10; //you can choose every column you wanna start with that column
Update 2 :
int rows = dataGridView1.Rows.Count;
int columns = dataGridView1.Columns.Count;
if (rows < 5 && columns < 10)
{
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
}
else
{
dataGridView1.FirstDisplayedScrollingRowIndex = 5; //use 5 because you want to start from 5
//you can have a horizontal scroll bar with this code :
dataGridView1.FirstDisplayedScrollingColumnIndex = 10; //you can choose every column you wanna start with that column
}