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

How to get the Cell Index in Data Grid Control

I am filling the Data Grid in the existing columns from the database.
In the Item_Command event of the Data Grid I am writing the code to be
execute while clicking on each item in the data grid. It is working. What is
the way for knowing which cell they click. With the item index I can get the
row. How I can get the column?
================Suresh
Aug 9 '06 #1
2 7113
Here is an example of some code I'm using to select a particular column in a
datagrid:

private void subsystemsCellChanged(object sender, MouseEventArgs e)
{
string subsystemSearch = "";
DataGrid.HitTestInfo hitInfo = subsystemsDataGrid.HitTest(new Point(e.X,
e.Y));
if (hitInfo.Row < datatableIndexTab.Rows.Count && hitInfo.Row -1)
{
subsystemsDataGrid.Select(hitInfo.Row);
subsystemsDataGrid.CurrentCell = new DataGridCell(hitInfo.Row,
hitInfo.Column);
DataGridCell dc = subsystemsDataGrid.CurrentCell;
string txt = subsystemsDataGrid[dc].ToString();
// do more processing here
}
}

HTH

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
"Suresh.P.R" wrote:
I am filling the Data Grid in the existing columns from the database.
In the Item_Command event of the Data Grid I am writing the code to be
execute while clicking on each item in the data grid. It is working. What is
the way for knowing which cell they click. With the item index I can get the
row. How I can get the column?
================Suresh
Aug 9 '06 #2
Hi,
Thanks.
============Suresh

"WhiteWizard" wrote:
Here is an example of some code I'm using to select a particular column in a
datagrid:

private void subsystemsCellChanged(object sender, MouseEventArgs e)
{
string subsystemSearch = "";
DataGrid.HitTestInfo hitInfo = subsystemsDataGrid.HitTest(new Point(e.X,
e.Y));
if (hitInfo.Row < datatableIndexTab.Rows.Count && hitInfo.Row -1)
{
subsystemsDataGrid.Select(hitInfo.Row);
subsystemsDataGrid.CurrentCell = new DataGridCell(hitInfo.Row,
hitInfo.Column);
DataGridCell dc = subsystemsDataGrid.CurrentCell;
string txt = subsystemsDataGrid[dc].ToString();
// do more processing here
}
}

HTH

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
"Suresh.P.R" wrote:
I am filling the Data Grid in the existing columns from the database.
In the Item_Command event of the Data Grid I am writing the code to be
execute while clicking on each item in the data grid. It is working. What is
the way for knowing which cell they click. With the item index I can get the
row. How I can get the column?
================Suresh
Aug 10 '06 #3

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

Similar topics

3
by: mefloyd | last post by:
Hello, I'd like to outline the current cell in an MSFlexGrid control with a certain color and line thickness. I thought of putting a shape control on the form and positioning it over the cell,...
1
by: James | last post by:
wxpython 2.5.3 hi, anyone know how to make a multiline cell editor for wxgrid? thank you :) best regards, James
3
by: Michael Schindler | last post by:
Hello NG How I can delete a specific cell in my Datagrid. I would like if the user is in the column 6 the value changed, after automaticly the value in the column 7 in the same row to delete....
0
by: Shravan | last post by:
Hi, I have a extended datagrid, in which I am setting values at a given cell in the grid using grid = val; The grid has NewRow creation set to false But sometimes setting value at a...
3
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data...
3
by: tjonsek | last post by:
am working on code that will allow users to update data within the datagrid. I have come across a few problems, some of them I have been able to work out, but this last one is giving me trouble. ...
3
by: Henry Jones | last post by:
I am using VB.NET VS 2005 and I have a datagridview bound to a table. This table has rate information on bank loans. The fiels are ProductName, MinDeposit, Rate, and PreviousRate On the grid...
0
by: bemanian | last post by:
Hi, This is a simple DataGridView in a windows form which contains a number of other controls as buttons, text boxes and so on. The problem is when the data grid cell editing is conducted via...
2
by: clogg02 | last post by:
Hi, I have bound a DataView to a DataGridView using this.dataGridView1.DataSource = new DataView(this.dataTable1); I allow for sorting of the datagridview using clicks on the headers. Later...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...

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.