473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

windows form datagrid questions

I have a datagrid on my windows form, it needs to be read only and when a
user selects a row, I want the whole row to be selected.

How would I go about doing this?

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
Nov 17 '05 #1
2 1445
http://www.syncfusion.com/FAQ/WinFor...44c.aspx#q689q

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Wayne" <Me******@community.nospam> wrote in message
news:Og**************@TK2MSFTNGP15.phx.gbl...
I have a datagrid on my windows form, it needs to be read only and when a
user selects a row, I want the whole row to be selected.

How would I go about doing this?

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute.
But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein


Nov 17 '05 #2
Hi Wayne

Interestingly, I've had to do exactly this today. If you start with the
Windows Forms FAQ (at Syncfusion), then that will get you started. I needed
row selection together with ReadOnly data, and also not having the text in
the cell highlighted when I clicked on it, and had to hack it together with a
MouseDown and MouseUp pair of handlers to set the Enable property on the
DataGrid to false, then to true while doing the selection - it felt like a
terrible hack (and I didn't test it much...), and would be interested to see
if other people have a more elegant way of achieving the same thing.

Nigel

private void DataGrid1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = this.DataGrid1.HitTest(pt);

if(hti.Type == DataGrid.HitTestType.Cell)
{

this.DataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
this.DataGrid1.Enabled = false;
this.DataGrid1.Select(hti.Row);
this.DataGrid1.Enabled = true;
}

}

private void DataGrid1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = this.DataGrid1.HitTest(pt);

if(hti.Type == DataGrid.HitTestType.Cell)
{

this.DataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
this.DataGrid1.Select(hti.Row);
}
}

Here's the code:

"Wayne" wrote:
I have a datagrid on my windows form, it needs to be read only and when a
user selects a row, I want the whole row to be selected.

How would I go about doing this?

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

Nov 17 '05 #3

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

Similar topics

3
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from...
4
by: John | last post by:
Hello all, I'm trying to display a dataset into a datagrid and format the datagrid columns but I'm having a hard time with it. I've tried the MSDN examples but they don't seem to work. ...
4
by: Carl Fenley | last post by:
I believe I have almost successfully created a custom datagrid control. The new class builds without error. I have added it as reference to the main Windows Application project. It appears on...
1
by: Richard | last post by:
Hello MyMainWebPage.aspx contains MyUserControl.ascx MyUserControl.ascx has a DataTable Property MyDataTable
7
by: Richard | last post by:
If the grid is dragged off the screen and back on the data is visible. Tried a dg.refresh() and Inactivate(). Can I do this by overriding custom base class OnPaint that my form inherits from? I...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
0
by: Simon Prince | last post by:
Hi I have created a .NET "Windows Custom Control" which is used an ASPX Web Form. It is referenced with the code, from a ASPX page. **************************************************...
1
by: Rajesh Kumar Choudhary | last post by:
Hi, I want to use the system.windows.form.datagrid control present in .net 2005 or 2003. Is it possible to use this? Please let me know if it is not supported. I have seen and used the classes...
3
Daxthecon
by: Daxthecon | last post by:
I'm using VS 2008 and Microsoft SQL Server Express Edition to program an ASP.NET/VB web application. The web application has to do with putting in products to populate a table veiwed by another page...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...

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.