473,888 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Column width in Datagrid does not set the correct value.


In Datagrid, while setting width of column through GridColumnStyle s
collection. width does not set to exact width that I am setting in my code.
If I set width to 13, it is changed to 130 or if set to 208, it changes to
On changing width of column I am resizing the width of grid. I am using
mouse down and mouse up events for this. On Mouse down, I store the position
and on mouse up, check the difference between positions and set the width of
column and grid. and because the column width does not set to exact value
that I get, usused area of grid get increased.

any solutions to this problem?

I am using following code:

private void dtgrdFixed_Mous eDown(object sender, MouseEventArgs e)
System.Drawing. Point pt = new Point(e.X, e.Y);
DataGrid.HitTes tInfo hti = dtgrdFixed.HitT est(pt);
if(hti.Type == DataGrid.HitTes tType.ColumnRes ize)
_bColResizeFlag = true;
_iColWidth =
dtgrdFixed.Tabl eStyles[0].GridColumnStyl es[hti.Column].Width;
_iColIndex = hti.Column;
_ptColResize = pt;
private void dtgrdFixed_Mous eUp(object sender, MouseEventArgs e)
System.Drawing. Point pt = new Point(e.X, e.Y);
DataGrid.HitTes tInfo hti = dtgrdFixed.HitT est(pt);
if (_bColResizeFla g)
if (_ptColResize.X != pt.X)
dtgrdFixed.Widt h += (pt.X - _ptColResize.X) ;
dtgrdFixed.Tabl eStyles[0].GridColumnStyl es[_iColIndex].Width +=
(pt.X - _ptColResize.X) ;
_bColResizeFlag = false;
Lalit Bhatia
Nov 17 '05 #1
0 1581

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: spmm_pls | last post by:
Hi, Could some1 please tell me what the best way is to adjust the value of a column in my databound datagrid (in ASP.NET) For example my database returns the values 1,2 and 3 in the column Priority. But 1,2 and 3 actually represent "Low", "Medium" and "High". So instead of a column filled with 1,2,3's I want a column filled with Low,Medium,High's. How do I do that??
by: Darryn Ross | last post by:
Hi, I am trying to display a long integer value from my access table in a Datagrid with a custom style applied to it and the value is not coming through correct?? database value = 0.00000 % datagrid value = 0.00 % How do i get my column style to display the details as they are in the
by: Mike L | last post by:
This is for a Win form, in C# 2005. I want to load a datagrid, make some columns width 0, and then clean out the record I added. I get the error message, ""Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"" I have tried, -1,0,1,2 for the index, and I get the same error message on each try.
by: Chris | last post by:
Hi, I'm using a DataGrid (in a Webform) for which I create custom-columns. BoundColumn organizationCol = new BoundColumn(); organizationCol.HeaderText = "Organization"; organizationCol.DataField = m_hashTable.ToString(); organizationCol.ItemStyle.Width = 50; dataGrid1.Columns.Add(organizationCol);
by: tshad | last post by:
I am trying to center a button in a datagrid column in asp.net and it doesn't seem to work. I have the following: <asp:TemplateColumn ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center"> <FooterTemplate> <asp:LinkButton CommandName="Insert" Text="<img src='..\images\Add.gif'border='0'>" ID="btnAdd" Runat="server" />
by: Luis Esteban Valencia | last post by:
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much in advance This is the code that loops through all rows. find the textboxes controls Private Sub btnguardarplandesarrollo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnguardarplandesarrollo.Click
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5 columns in it but i need to add a sixth column which will be my checkbox column - any help or pointers with this would be great
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is freeze.
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.