.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

Columns collection of a DataGridView within a UserControl won't serialize to designer

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :.NET Framework
First of all, I've found this issue on connect which describes my problems exactly, however, I've been able to find a workaround but I don't find it acceptable so I appeal to you for an idea of how to resolve this as cleanly as possible. What I've done is, I've applied a custom designer to my UserControl like so [Designer(typeof(CustomControlDesigner))]public partial class DataGridViewTag : UserControl, ISupportInitialize In the CustomControlDesigner I don't do much at this point, I set selection rules and add a few DesignerVerbs. The important thing is, I also EnableDesignMode for the DataGridView in my UserControl. Then, I expose DataGridView's DataSource and Columns collection like this: [Editor(typeof(CollectionEditor), typeof(UITypeEditor))][Category("Grid")][DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]public DataGridViewColumnCollection Columns{    get { return dgvList.Columns; } set { dgvList.Columns.Clear(); foreach (DataGridViewColumn col in value) dgvList.Columns.Add(col); }} [AttributeProvider(typeof(IListSource))] [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] [Category("Grid")] public object DataSource{ get { return dgvList.DataSource;&nbs

View Complete Post

More Related Resource Links

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

How to create scrolling table for columns in a SharePoint Designer Data View


I have a fairly complex SharePoint Designer 2007 Data View they have added two more requirements.

1. Have the columns on the right side be able to scroll left to right as there is a large number of columns, while the first 3 columns on the left side stay locked in place.  This is only one list not two, and because of some other requirements I have it must remain to be just one list.

2. Then they also need to have scrolling up and down of the entire list with the headers locked in place.

The first requirement is more important than the second, but preferrably I need to do both.

I am new to XSL so not familar with the syntax. Is this something I can do on a custom Data View? Does anyone have any examples of how?

I have a drawing that show how it needs to look but I don't see an option here to upload a graphic.

So here is a link to my graphic example uploaded to my blog area: http://lindachapman.blogspot.com/  or just the image here: http://4.bp.blogspot.com/_aB01ue__NvQ/TGL42MOvrGI/AAAAAAAAAA4/c3xP4uCy4BU/s1600/Scrolling.png

I failed to mention that 3/4 of the columns are HTML Calculated fields wh

DataGridView>Edit Columns> Column Read Only property is unwilling to change

Hello, I am facing the following mystery: When changing the read only property of a column to false and reopening the "edit columns" window, it mysteriously turns back to true. Even when closing the designer and changing it in the designer code, the resulting execution does not allow edit, as well as when re-opening the designer you see true again.             this.numberDataGridViewTextBoxColumn1.DataPropertyName = "Number";             this.numberDataGridViewTextBoxColumn1.HeaderText = "Number";             this.numberDataGridViewTextBoxColumn1.Name = "numberDataGridViewTextBoxColumn1";             this.numberDataGridViewTextBoxColumn1.ReadOnly = true;//False is required We thought it might be related to data binding. rebinding the grid did not help as well. The is no other place in the code where it changes. Please advice, Thanks

DataGridView freeze columns issue

When i try to freeze a column that is off screen (to the right) when the DataGridView's (DGV) first displayed column is the first column in the DGV, the DGV refreshes and displays the DGV from the first column in the DGV. Also, the horizontal scrollbar on the bottom of the page disappears.  This means that i cannot see the unfrozen columns and i cant get over to view the column that I froze. This seems to behave differently from freezing a column in Excel, which freezes the columns you are currently viewing at that moment (not sending you back to the first row) and then the scroll bar applies to the frozen columns like normal. Is there a workaround for this? I tried setting the first displayed index for the column and I get an exception. I'm using .NET 3.5 on an XP machine.

Struggling to remove ellipses when columns in a DataGridView are automatically truncated

Hi all, I've got approx. 20 columns in a DataGridView so screen real estate is a little limited! All the columns have a fixed width, and in my old DataGrid when the content was too big for cell it would simply disappear off the edge so a cell containing 'flibberty' would be in the table cell |flibber| In contrast, with datagridview this becomes |flibb...| - I'd really really like to get rid of these ellipses and get the old DataGrid behaviour for this case - but it doesn't seem straightforward at all, can anyone help? Thanks, Henri

usercontrol layout in canvas at runtime puts in mult. copies of 1st element in collection.

I created a usercontrol which has a few DP's that match up with fields in a sql table. The requirements of this control specify if I get a specific status value I will flash the usercontrol to draw attention to a specific area of equipment in the facility. I also provide a tooltip which has all the fields of data to view. The usercontrol should only display it's description. On a button click I run the following code which instantiates a new observablecollection of my custom usercontrol (I call it profiNode). It then fills a dataset by calling our DAL and then I loop through the datarows using the values to create a new profiNode object for each row. I then add these to the observable collection, but I suppose a generic list would work too.     ProfiNodes = new ObservableCollection< profi.profiNode > (); DataSet data = new DataSet(); data = this.DataLayer.getDataSet("Select * from ProfibusMapping", CommandType.Text, null); foreach (DataRow row in data.Tables[0].Rows) { profi.profiNode node = new profi.profiNode((string)row.ItemArray[0],(int)row.ItemArray[1], (int)row.ItemArray[2], (int)row.ItemArray[3], (string)row.ItemArray[4], (DateTime)row.ItemArray[5], (int)row.ItemArray[6], (int)row.ItemArray[7], (string) row.ItemArray[8], (double)row.ItemArray[9], (double)row.ItemArray[10]); node.ID = string.Format("node_M{0}_A{1}&q

How to change the size (width) of scorecard columns in Dashboard Designer?

Is there any way to change the size (width) of scorecard columns in Dashboard Designer?

Binding DataGridView --- DataSet or Collection

This is my experiences. I can bind the DataGridView using DataSet and Collection. 1st expericence, If using DataSet, my DataGridView have an empty row at the last row (have to set AllowUserToAddRows Property to False). If using Collection, my DataGridView do not have empty row at the last row. 2nd experience, I know how to rebind the DataGridView using DataSet. But I dont know how to rebind the DataGridView using Collection. My collection as follow, private Collection<MasterAgentCompany> myDGV = new Collection<MasterAgentCompany>(); private BindingSource bindingSource = new BindingSource(); dgv1.DataSource = bindingSource; bindingSource.DataSource = myDGV; dgv1.Refresh(); /*THIS CODE IS OK ON 1ST TIME LOAD*/ /*IF I'M CALLING THIS CODE AGAIN, MY DATAGRIDVIEW NOT REFRESH THE NEW RECORD*/ I'm looking the right technique to rebind DataGridView using Collection I'm stuck. Really looking for help

Creating a pivot of a collection and displaying it in a databound grid with dynamic columns



I'm trying to create a pivot of some data that I have about translation.

Basically what I have now is a collection of "Translation" objects which look like that :

Public Class SystemText
  Inherits Entity

#Region "Private variables"
  Private _textCategory As String
  Private _textName As String
  Private _languageCode As String
  Private _description As String
#End Region

#Region "Properties"
  Public Overridable Property TextCategory() As String

Is it possible to remove 'SharePoint Designer Settings' link from Site collection Adminitration Se

Is it possible to remove the link 'SharePoint Designer Settings' from the Site Collection Administration section of settings page.

UserControl - wrong namespace in designer


hi, I create a Empty SharePoint Project in VS 2010. I add two UserContsrol's (uc1 and uc2) to the project. VS create a new folder "ControlTemplates" and there are my uc.:


I have textbox1 on uc1 (i send textBox1 value with properties) and button1 and textbox1 on uc2 .


I add uc1 to uc2 :


Everything will be ok but in uc2.ascx.designer.cs i have some like that:



 uc2 { 



 uControl1 control. /// </summary> ///
 <remarks> ///
 Auto-generated field.

SP Designer 2010 Conditional Formatting with Hidden Values/Columns


I have a list with 30~40 columns. I want to do conditional formatting on it using SharePoint 2010 Designer (instead of creating a visual webpart with vs2010).

Of the 30-40 columns, i am only viewing 5 columns that i need (ie: first name, last name, etc...)

I can create the XSLT ListView Webpart on the page within SharePoint 2010. I can edit it with SharePoint 2010 Designer, i can also apply conditional formating to the row (ie: select row within XSLT webpart > Options > Conditional Formatting).

However, i cannot apply the conditional formatting too columns that are not listed in the <ViewFields> of the <XmlDefinition>. What gives? I want to do conditional formatting on the entire row of the item using the hidden ten or so columns and i don't want the user to see all the columns, but i want to do conditional formatting on them (its for æsthetics reasons, i don't want a grid list of 15+ columns on someones poor 1024 by 768 resolution/monitor... plus they don't need to see it until they click into the list item....)


<FieldRef Name="SomeColumnName" Hidden="True" /> does not work
<FieldRef Name="SomeColumnName" ReadOnly="True" /> does not work either

Designer Workflow: update list in another site within collection?

Is it possible with a Designer 2007 created workflow to update an list in another site within the same collection?  I don't see a way to do that and am wondering if I am missing something.
There are no mistakes; every result tells you something of value about what your are trying to accomplish.

Sharepoint Designer 2010 - How to add custom columns to lists



When creating a new view - I would like to add an extra column which I could use as a custom hyperlink to fire up the EditForm.aspx or my on custom ediform.  I would like it.  Is there a step by step that shows hwo to do wthis with SP 2010 and SPD 2010?

Thanks in advance



Problem with resizing DataGridView columns

When i resize a column in a DataGridView control the Click event is fired. Is there a way to prevent that?

Serialize Strong Typed Collection. "There was an error reflecting type.."



I have a class that looks like this:


public class NewsItems : System.Collections.Generic.List<NewsItem>



Any it works just fine for 99% of my needs... Here is the 1% problem, when I want to write out the contents of my collection to XML, I get the following error (pasted below) anyone know how to remedy this?

System.InvalidOperationException was unhandled
  Message="There was an error reflecting type 'NewsItems'."
       at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel)
       at System.Xml.Serialization.XmlReflectionImporter.ImportElement(TypeModel model, XmlRootAttribute root, String defaultNamespace)
       at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defau

New site columns added using xml,not shown in existing site collection


I have added new site columns to the existing content type using xml,deployed to a sharepoint application as a feature using VS2010. Now my problem is the site columns are not updated in existing pages under site coolection,it is showing only the existing site columns and not the new site columns. I then tried adding those site columns to the pages library manually,after that it is displaying those columns in pages and i can enter text in edit mode but whenever i save the page it is rendered with some tags like <span id="msrterangecursor">. It is shown for only new site columns.

Could anyone help with this.

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