Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto-highlight row in datagrid

Status
Not open for further replies.

jrwinterburn

IS-IT--Management
Jul 26, 2004
72
GB
Hi Guys,

I cannot seem to get my datagrid to do what I want. When I run my form, the first row is selected (that's fine) but the first cell is selected with a cursor in it (not fine) whereas I'd rather either no cell or row is selected, or the first row is highlighted (no cursor).

When I click on another row, the row is fully selected which is what I want, but I can't get it to auto-highlight the first row.

Any ideas?

Thanks,

Jon
 
In the Form_Load event - make sure its after you load data into the grid - try this:

DataGrid1.CurrentRowIndex = 0
DataGrid1.Select(DataGrid1.CurrentRowIndex)

Substitute your grid's name for DataGrid1, of course.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Thanks for that but it makes no difference - I was already using DataGrid1.Select(DataGrid1.CurrentRowIndex) to highlight the row - when I add DataGrid1.CurrentRowIndex = 0 it makes no difference - the first cell of the highlighted row still appears in edit mode, inasmuch as the cursor is blinking on that cell and it is grey. I can't see to get rid of that cursor!
 
you could turn off edits ;)

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top