473,388 Members | 1,526 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,388 software developers and data experts.

Select a COLUMN in a datagrid?

Hi,

Can anyone suggest how to select or hilight a column in a Windows
Forms datagrid, as visual feedback for an edit/copy command?

I've tried ...

private void mydatagrid_Mousedown(object sender, MouseEventArgs e)
{
// Determine location of mouse click.
DataGrid.HitTestInfo hit = mydatagrid.HitTest(e.X, e.Y);
if (hit.Type == DataGrid.HitTestType.ColumnHeader)
{
DataGridTextBoxColumn col = (DataGridTextBoxColumn)
mydatagrid.TableStyles[0].GridColumnStyles[hit.Column];
DataGridTextBox dt = (DataGridTextBox) col.TextBox;
dt.BackColor = System.Drawing.Color.Red; // just for test
}
}

.... from a snippet somewhere in the MSDN library, but this causes
cells in the hit column to have a red background only if and while
they become selected; otherwise they appear normal. Any suggestions,
or another approach altogether?

Roger.
Nov 22 '05 #1
4 1527
Check out:
http://www.syncfusion.com/faq/winforms/search/893.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Roger Lainson" <ro***@sdr.com.au> wrote in message
news:23**************************@posting.google.c om...
Hi,

Can anyone suggest how to select or hilight a column in a Windows
Forms datagrid, as visual feedback for an edit/copy command?

I've tried ...

private void mydatagrid_Mousedown(object sender, MouseEventArgs e)
{
// Determine location of mouse click.
DataGrid.HitTestInfo hit = mydatagrid.HitTest(e.X, e.Y);
if (hit.Type == DataGrid.HitTestType.ColumnHeader)
{
DataGridTextBoxColumn col = (DataGridTextBoxColumn)
mydatagrid.TableStyles[0].GridColumnStyles[hit.Column];
DataGridTextBox dt = (DataGridTextBox) col.TextBox;
dt.BackColor = System.Drawing.Color.Red; // just for test
}
}

... from a snippet somewhere in the MSDN library, but this causes
cells in the hit column to have a red background only if and while
they become selected; otherwise they appear normal. Any suggestions,
or another approach altogether?

Roger.

Nov 22 '05 #2
Check out:
http://www.syncfusion.com/faq/winforms/search/893.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Roger Lainson" <ro***@sdr.com.au> wrote in message
news:23**************************@posting.google.c om...
Hi,

Can anyone suggest how to select or hilight a column in a Windows
Forms datagrid, as visual feedback for an edit/copy command?

I've tried ...

private void mydatagrid_Mousedown(object sender, MouseEventArgs e)
{
// Determine location of mouse click.
DataGrid.HitTestInfo hit = mydatagrid.HitTest(e.X, e.Y);
if (hit.Type == DataGrid.HitTestType.ColumnHeader)
{
DataGridTextBoxColumn col = (DataGridTextBoxColumn)
mydatagrid.TableStyles[0].GridColumnStyles[hit.Column];
DataGridTextBox dt = (DataGridTextBox) col.TextBox;
dt.BackColor = System.Drawing.Color.Red; // just for test
}
}

... from a snippet somewhere in the MSDN library, but this causes
cells in the hit column to have a red background only if and while
they become selected; otherwise they appear normal. Any suggestions,
or another approach altogether?

Roger.


Nov 22 '05 #3
Hi Rob,

What a great website - everything I've ever wanted to know about
datagrids and a whole lot more besides. Many thanks!

Roger.

"Rob Windsor [MVP]" <rw******@NO.MORE.SPAM.bigfoot.com> wrote in message news:<ua**************@TK2MSFTNGP10.phx.gbl>...
Check out:
http://www.syncfusion.com/faq/winforms/search/893.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
"Roger Lainson" <ro***@sdr.com.au> wrote in message
news:23**************************@posting.google.c om...
Hi,

Can anyone suggest how to select or hilight a column in a Windows
Forms datagrid, as visual feedback for an edit/copy command?

...

Nov 22 '05 #4

Hi Roger,

Thanks very much for your feedback.

Yes, http://www.syncfusion.com/FAQ/WinForms/default.asp is an informative
website for WinForm FAQ.
You can find a lot of WinForm related tips from it.

I am glad you find what you want, if you have any further concern, please
feel free to post, I will help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #5

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

Similar topics

4
by: Terry | last post by:
Hey, Having somewhat of an issue, I have a datagrid which is giving me issues. The Datagrid is setup for the user to double click the row, the row is selected and data within that row populates a...
4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
2
by: Bajgon | last post by:
Hello, I have got a DataGrid and a DataTable, which is its DataSource. I can use DataTable.Rows.Find(key_value) method to locate any row in the DataTable, using values of key column. The...
2
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
4
by: sakieboy | last post by:
I currently have a datagrid with several columns. The first column in the DataGrid is a HyperLinkColumn. When I select a row, I would like for this HyperlinkColumn to fire. I have the mouseover...
0
by: xiaozozo | last post by:
hi everyone, im having a small problem here.. currently using a datagrid to display data from my DB, and using button column "select" as my first column. the text field is set as one of the...
4
by: Geoff | last post by:
Hi Can anybody tell me how to prevent multiple selections of rows in a datagrid? Also, can anybody tell me if the following are available in the latest version of the DataGrid i.e. in visual...
3
by: CharlesA | last post by:
Hi folks, I really need help with the following scenario, I'm going to describe as well as a I can what the setup is and what I can't understand I'm using the framework 1.1 using ASP.net with...
18
by: rcoco | last post by:
Hi all, I have a datagrid with Button column select in form of hyperlink. On the same page, I have another datagrid that insert data and one column(Name) has Names of a user that is inserting...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.