.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

Problem with resizing DataGridView columns

Posted By:      Posted Date: October 27, 2010    Points: 0   Category :Windows Application
When i resize a column in a DataGridView control the Click event is fired. Is there a way to prevent that?

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

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

Problem displaying a page using window.showModalDialog when resizing it.

 Hi, I have a page that is displayed using window.showModalDialog, when the page is resized the tables, text boxes and everything else that is in the page with the width 100% doesn't resize (fit the page) unless a post back is used.How can I make the page keep everything in proportion when it is resized without the need to post back? 

problem in make editable a combobox in datagridview in c#

how do i make my datagridview combobox aditable for the user while i has a drop down list. in this case sometimes user needs to edit the selected item from the list.how can i implement this?

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

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

problem seems to be related to grouping by on columns with the same name in different tables


using OLEDB provider IBMDADB2.1

and the following SQL run from ReportBuilder


sect.name as Team,

tasktype.name as TaskType,










The SQL runs fine in a DB2 query tool but when run through ReportBuilder I get

[DB2/LINUXX8664] SQL0119N  An expression starting with "TASKTYPE" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified.  SQLSTATE=42803


Basically the problem seems to be related to grouping by on columns with the same name in different tables.

Anyone know a work around?

Regarding Telerik RadGrid Control Resizing problem in MOSS2007


If I have telrik control of radGrid in user control1 ....

That user control1 I have specified in another user control2 through Register tagprefix.

Now in UserControl1 ,I have just mentioned the Definition of rad grid and not specified columns.

The columns I am generating in UserControl2 programatically.

The column I am generating is of type GridTemplateColumn ,Now plaease suggest that How can radgrid column can be resized by user at run time programatically?

MOSS 2007 Strange Problem with edit forms, content types and document library columns


I'm having a strange problem and have not been able to track down any useful answers over google.

I inherited a SharePoint site that I am now making some changes to.

I am having problems with one document library.  We had custom edit forms on this document library, which I was finding a pain to maintain so I reset them back to the site definition.  This edit form now shows only those fields that are associated with the Document content type (the only content type - I've deleted the others) on the document library.  There are other columns on this document library that are NOT associated with the content type that I would like to show on the edit form but they are not available when I try to add them to the content type via Settings > Document Content Type > Add from existing site or list columns.  The select columns from drop down is set to List Columns.  The Additional Authors column is just not there.

I CAN see this field on the all items view for the document library, it is there and populated with data.

Setting the Allow Managed content types radio button to NO does not have any impact on which fields are visible on the form- I still see those same fields that have been associated with the Document content type.

Has anyone else seen this or does anyone have any thoughts?? 

They will be muc

Problem with gridview dynamically generated columns and textboxes


Hi All,

 I am using asp.net/c# application. In my application, I have a gridview.

<asp:GridView id ="gv_QuestionList" runat="server"> </asp:GridView>

In Code Behind, I created dynamic textboxes and DropDownLists on RowDataBound.

protected void gv_QuestionList_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)

                if (ObjQMDO.QuestionType == "TextBox")
                    TextBox txt = new TextBox();
                else if (ObjQMDO.QuestionType == "Dropdownlist")
                    DropDownList drp = new DropDownList();
                    drp.DataSource = ObjQMDA.GetQuesTypeValues(QUES_ID);
                    drp.DataTextField = "QTYV_QuesTypeValue";
                    drp.DataValueField = "QTYV_ID";
                    drp.Items.Insert(0, new ListItem("Select One", "0"));

                else if (ObjQMDO.QuestionType == "Radio")

Problem with List Columns in Foundation 2010 when Importing from Excel


This is a pretty detailed issue. I will give you all the steps I am doing and hopefully there is a solution.

I recently updated our intranet site from WSS 3.0 to SharePoint Foundation. In WSS 3.0 I added a few of the application templates to use, including Asset Tracking. When I moved to Foundation I decided not to use those (and not sure if I can anyway) and exported the Asset Tracking data to Excel, then imported it to Sharepoint Foundation as a list.

Here is the issue I am having: when I imported from Excel all but one of the columns was created as "multiple lines of text". This means I cannot sort by these columns. I thought I could create similar columns as single lines of text, export back to Excel, copy the data, and import back. This changes the columns again to multiple lines. I even tried just typing in the data as a test and same problem. As long as there is no data, the columns will remain as single line of text; but as soon as I put data in I get this issue.

I can cofirm that these columns do not have more text than should be available in a single line. Any ideas of what I can do to make this work? I am at my wits end on this.

Thanks for any and all help.

Problem trying row filtering - Need Filter Template for string columns


I'm still really new at DD.

I need to do straightforward filtering of tables on columns that are simple string/text/varchar type.

I'm trying to follow the direction given in http://blogs.msdn.com/b/morebits/archive/2009/04/14/customize-table-rows-filtering-in-dynamic-data.aspx 

 I have added the DynamicFilter in my markup like this:

<asp:DynamicFilter ID="SellerFilterID" DataField="SellerUserId" runat="server" OnFilterChanged="DynamicFilter_FilterChanged" />

I have added the QueryExtender and Dynamic Filter expression like this:

            <asp:QueryExtender ID="CustomerCustomQueryExtenderID" TargetControlID="GridDataSource" runat="server">
                <asp:DynamicFilterExpression  ControlID="SellerFilterID" />
I get the error that I expected because the blog warned that "It will throw a 

DataGridView Problem


Hi I have a problem with my datagridview vb.net i'm using modules, stored procedures, sql server and I need to update spaces in my database for example and search a name datagrid show me result and a i want to modify from my datagrid values to my database the stored procedues are call from modules to form


Thanks, greetings

Matrix Row Group or Columns Group layout problem


I am trying to creating a Matrix that displays Appointments sorted by Time  (expample below)

11/22/2010  7:3O AM







Problem with resizing images and padding them to squared images before binding them to grid



I am developing a web application in ASP.NET and C# using Visual Studio 2008. The application will among other thing store images into a database in the original format and in some resized formats. I have this method that takes an image as argument and returns an image with the specified size:

thumbnailmage = ResizeImage(originalImage, new Size(50,50));

The image returned is proportional to the original image with no side bigger than 50 pixels. E.g. if the originalImage has width 100 and height 200 the resized image has width 25 and height 50. This result is expected and wanted.

Now, to what I really want. I want to modify the ResizeImage method to return a squared thumbnail. I.e. in the originalImage example sizes above, the returned image should have width width and heigth both 50. Also, the image should not be stretched but padded with 12.5 pixels on the left and right side making the width 50. The image format I currently work with is gif with transparent background so the padded image parts should also be tansparent. Here is the code for ResizeImage, does anyone know how it could be modified?

  private static Image ResizeImage(Image imageToResize, Size size)
      int sourceWidth = imageToResize.Width;
      int sourceHeight = imageToResize.Height;


Window resizing problem?


Hi all,

This is my first post and i am not sure how to start explaining my problem, but i want to try.  I am designing a WPF app. The problem i am facing is related to resizing the app's window. I will break the app into the components i am using to give a better picture.



1. A panel - left hand side

2. A tab usercontrol with four tabs(A,B,C,D) - right hand side.


tab A has a text editor from another xaml file(on left hand side) AND another display on the right hand side. Now when i try to resize the window after building the app, the window just starts to hide the display on the left hand side by eating it up.


Is there a function/variable in the WPF designer that i can use to do the resizing such that the compnents in the window will adjust there sizes to accomodate with the mainwindow size??





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