473,586 Members | 2,718 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 2205
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
2563
by: sailu | last post by:
Hi, Anyone knows how can i set the focus to a particular cell in DataGrid. Thanks, Sailaja.
3
2985
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 it? I've tried to bind the TextBox using the VS IDE (which ended up in binding to a table column). This was perfect until I used the Update...
10
45181
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 event..., to no avail Any ideas Regards
2
14455
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 click event. Using newrowindex for the row how can I move the focus?
5
20307
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 clicked or tabbed into even though I have set the focus back to the rouge row with a .selected = true property. I have tried the following with no...
0
1502
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" encoding="UTF-8"> <maincategory> <cat1> <title>Category1</title>
1
10805
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
13592
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 display in a textbox below the datgridview. I currently have it fixed so if you click on a row the note field from that row is put in the textbox. ...
1
2155
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
4055
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
7911
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, 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...
0
8200
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, 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. ...
0
8338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8215
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 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...
0
6610
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3836
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...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1179
bsmnconsultancy
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...

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.