473,508 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to set focus to a particular cell using the datagridview

1 New Member
hi friends, I need to set focus in a corresponding cell in datagridview C# dot net, help me
Aug 7 '07 #1
1 2196
Plater
7,872 Recognized Expert Expert
You are in luck!
I happened to have had to look up the code for a post not too long ago
Expand|Select|Wrap|Line Numbers
  1. // My DataGridView is called dgvParts
  2. // My function is going down the column with the header "PartID" and checking 
  3. // to see if the value in that cell matches the one I want.
  4. // When I find it, I set the .CurrentCell property of my DataGridView to it
  5.  
  6. private void SelectPartIDMatching(string PartID)
  7.         {
  8.             int myidx = -1;
  9.             for (int i = 0; i < dgvParts.Rows.Count; i++)
  10.             {
  11.                 if (dgvParts["PartID", i].Value.ToString() == PartID)
  12.                 {
  13.                     myidx = i;
  14.                     break;
  15.                 }
  16.             }
  17.             if (myidx != -1)
  18.             {
  19.                 //this is the important line
  20.                 dgvParts.CurrentCell = dgvParts.Rows[myidx].Cells[0];
  21.             }
  22.         }
  23.  
Aug 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2559
by: sailu | last post by:
Hi, Anyone knows how can i set the focus to a particular cell in DataGrid. Thanks, Sailaja.
3
2980
by: nvx | last post by:
Hello everyone... Just for the record, I'm a newbie to this data binding thing... In my C# application I need to bind a cell of an Access database table to a multiline TextBox. How should I do...
10
45150
by: steve | last post by:
Hi All I would like to be able to change the cell borders on certain cells to none at runtime to make a group of cells appear to be merged I have tried the following in the cellformatting...
2
14445
by: Paul Remblance | last post by:
I am trying to use the bindingnavigator addnewitem button to place the focus on the first cell in the newrow row. I have disabled the default action and I am using the bindingnavigatoraddnewitem...
5
20298
by: svaradan | last post by:
Hi I have an issue wherein when the RowLeave event is trigerred ina datagridview, I want to set the focus back to the row where the validation failed. But the cell focus goes to the cell i...
0
1495
by: ajanu81 | last post by:
hi all, i am new to this forum. i am using a windows application using C#. I am using a datagridview to display contents of a xml file. say i have a xml file like this. <xml version="1.0"...
1
10784
mafaisal
by: mafaisal | last post by:
How to Focus Particular Cells of Datagridview in vb.net ie, in FlexGrid We got focus by With flexgrid1 .Row=0 .col=1 .focus end with then we get focus on col1 in Datagridview how get it..?
12
13567
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
1
2141
nev
by: nev | last post by:
i can select a particular dgv cell by... dgv.currentcell = dgv.rows(i).cells(i) but how can i activate the blinking cursor in it so that it's ready to accept text input?
5
4053
by: Andrus | last post by:
Steps to reproduce issue: 1. Run code. 2. Enter some data to grid 3. Click other form caption 4. Click original form caption 5. Enter some characters Observed: entered characters are ignored
0
7231
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
7132
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
5640
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,...
1
5059
isladogs
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...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
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...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.