Datagridview.Rows(#).Selected not updating CurrentRow.IndexVB.NET Winforms DataGridView Select new row on Sorted DataGridViewUpdating datagridview from another form in vb.netDisable group selection on ListView Control WinFormsDynamically added DataGridViewdatagridview disable user moving through/selecting cells/rowsHow to Update the selected Data in datagridview after it sorted/order?How to select multiple rows OR columns keeping “Ctrl” pressed in DataGridView objectThe selection(highlighting) of an item using the arrow keys are overwritten by the previous mouse pointer selection in a ContextMenuStripUpdating mysql data in VB.NET not workingRetrieve Values from a sorted and data bound datagridview

Took a trip to a parallel universe, need help deciphering

Neighboring nodes in the network

Is there a hemisphere-neutral way of specifying a season?

Emailing HOD to enhance faculty application

Blender 2.8 I can't see vertices, edges or faces in edit mode

Why do I get two different answers for this counting problem?

How to show the equivalence between the regularized regression and their constraint formulas using KKT

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

Arrow those variables!

Can I use a neutral wire from another outlet to repair a broken neutral?

Forgetting the musical notes while performing in concert

Why is Collection not simply treated as Collection<?>

Can a rocket refuel on Mars from water?

Today is the Center

What's the point of deactivating Num Lock on login screens?

What is the word for reserving something for yourself before others do?

How to draw the figure with four pentagons?

Did Shadowfax go to Valinor?

Is it possible to run Internet Explorer on OS X El Capitan?

Python: return float 1.0 as int 1 but float 1.5 as float 1.5

What does it mean to describe someone as a butt steak?

Fully-Firstable Anagram Sets

A reference to a well-known characterization of scattered compact spaces

What is the PIE reconstruction for word-initial alpha with rough breathing?



Datagridview.Rows(#).Selected not updating CurrentRow.Index


VB.NET Winforms DataGridView Select new row on Sorted DataGridViewUpdating datagridview from another form in vb.netDisable group selection on ListView Control WinFormsDynamically added DataGridViewdatagridview disable user moving through/selecting cells/rowsHow to Update the selected Data in datagridview after it sorted/order?How to select multiple rows OR columns keeping “Ctrl” pressed in DataGridView objectThe selection(highlighting) of an item using the arrow keys are overwritten by the previous mouse pointer selection in a ContextMenuStripUpdating mysql data in VB.NET not workingRetrieve Values from a sorted and data bound datagridview






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















VB.Net 4.6.1
Windows Forms application



I have a bound datagridview that I'm trying to sort and select. The data loads fine and I can click the headers (with some code) and the sorting works well. I'm working on reselecting a record after the sort is complete and I'm running into some trouble.



Assume that I have a datagridview with 20 records in it. On the form I also have a button that runs the following:



MessageBox.Show(MyDataGridView.CurrentRow.Index.ToString)


I also have a Sub that handles MyDataGridView.Sorted and in it I have one test line as follows:



MyDataGridView.Rows(2).Selected = True


After the data loads I click on the 11th record (selectionmode fullrowselect) and then I click the button. Box pops up and says "10" (0 based index). I click one of my column headers, the data sorts and the highlight bar jumps up to the 3rd record (index 2). However when I hit my currentrow.index button it still says 10. Additionally if I hit the down arrow key the selection bar jumps down to the 11th (index 10) record in the list.



It seems that using "Selected" doesn't update the currentrow.index value and since it is read-only I can't force it. Can anyone educate me on what's going on because, as it is, my users would be confused if the arrow up and down keys didn't work properly after a sort.



Thank you!










share|improve this question






















  • Not exactly sure what you are trying to do, but you can set either dgv.CurrentCell or dgv.CurrentCellAddress to update the dgv.CurrentRow.Index.

    – TnTinMn
    Mar 21 at 22:32











  • Setting CurrentCell worked just fine. Thank you TnTinMn

    – GunnerFan420
    Mar 22 at 14:20

















0















VB.Net 4.6.1
Windows Forms application



I have a bound datagridview that I'm trying to sort and select. The data loads fine and I can click the headers (with some code) and the sorting works well. I'm working on reselecting a record after the sort is complete and I'm running into some trouble.



Assume that I have a datagridview with 20 records in it. On the form I also have a button that runs the following:



MessageBox.Show(MyDataGridView.CurrentRow.Index.ToString)


I also have a Sub that handles MyDataGridView.Sorted and in it I have one test line as follows:



MyDataGridView.Rows(2).Selected = True


After the data loads I click on the 11th record (selectionmode fullrowselect) and then I click the button. Box pops up and says "10" (0 based index). I click one of my column headers, the data sorts and the highlight bar jumps up to the 3rd record (index 2). However when I hit my currentrow.index button it still says 10. Additionally if I hit the down arrow key the selection bar jumps down to the 11th (index 10) record in the list.



It seems that using "Selected" doesn't update the currentrow.index value and since it is read-only I can't force it. Can anyone educate me on what's going on because, as it is, my users would be confused if the arrow up and down keys didn't work properly after a sort.



Thank you!










share|improve this question






















  • Not exactly sure what you are trying to do, but you can set either dgv.CurrentCell or dgv.CurrentCellAddress to update the dgv.CurrentRow.Index.

    – TnTinMn
    Mar 21 at 22:32











  • Setting CurrentCell worked just fine. Thank you TnTinMn

    – GunnerFan420
    Mar 22 at 14:20













0












0








0








VB.Net 4.6.1
Windows Forms application



I have a bound datagridview that I'm trying to sort and select. The data loads fine and I can click the headers (with some code) and the sorting works well. I'm working on reselecting a record after the sort is complete and I'm running into some trouble.



Assume that I have a datagridview with 20 records in it. On the form I also have a button that runs the following:



MessageBox.Show(MyDataGridView.CurrentRow.Index.ToString)


I also have a Sub that handles MyDataGridView.Sorted and in it I have one test line as follows:



MyDataGridView.Rows(2).Selected = True


After the data loads I click on the 11th record (selectionmode fullrowselect) and then I click the button. Box pops up and says "10" (0 based index). I click one of my column headers, the data sorts and the highlight bar jumps up to the 3rd record (index 2). However when I hit my currentrow.index button it still says 10. Additionally if I hit the down arrow key the selection bar jumps down to the 11th (index 10) record in the list.



It seems that using "Selected" doesn't update the currentrow.index value and since it is read-only I can't force it. Can anyone educate me on what's going on because, as it is, my users would be confused if the arrow up and down keys didn't work properly after a sort.



Thank you!










share|improve this question














VB.Net 4.6.1
Windows Forms application



I have a bound datagridview that I'm trying to sort and select. The data loads fine and I can click the headers (with some code) and the sorting works well. I'm working on reselecting a record after the sort is complete and I'm running into some trouble.



Assume that I have a datagridview with 20 records in it. On the form I also have a button that runs the following:



MessageBox.Show(MyDataGridView.CurrentRow.Index.ToString)


I also have a Sub that handles MyDataGridView.Sorted and in it I have one test line as follows:



MyDataGridView.Rows(2).Selected = True


After the data loads I click on the 11th record (selectionmode fullrowselect) and then I click the button. Box pops up and says "10" (0 based index). I click one of my column headers, the data sorts and the highlight bar jumps up to the 3rd record (index 2). However when I hit my currentrow.index button it still says 10. Additionally if I hit the down arrow key the selection bar jumps down to the 11th (index 10) record in the list.



It seems that using "Selected" doesn't update the currentrow.index value and since it is read-only I can't force it. Can anyone educate me on what's going on because, as it is, my users would be confused if the arrow up and down keys didn't work properly after a sort.



Thank you!







vb.net






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 21 at 21:56









GunnerFan420GunnerFan420

777




777












  • Not exactly sure what you are trying to do, but you can set either dgv.CurrentCell or dgv.CurrentCellAddress to update the dgv.CurrentRow.Index.

    – TnTinMn
    Mar 21 at 22:32











  • Setting CurrentCell worked just fine. Thank you TnTinMn

    – GunnerFan420
    Mar 22 at 14:20

















  • Not exactly sure what you are trying to do, but you can set either dgv.CurrentCell or dgv.CurrentCellAddress to update the dgv.CurrentRow.Index.

    – TnTinMn
    Mar 21 at 22:32











  • Setting CurrentCell worked just fine. Thank you TnTinMn

    – GunnerFan420
    Mar 22 at 14:20
















Not exactly sure what you are trying to do, but you can set either dgv.CurrentCell or dgv.CurrentCellAddress to update the dgv.CurrentRow.Index.

– TnTinMn
Mar 21 at 22:32





Not exactly sure what you are trying to do, but you can set either dgv.CurrentCell or dgv.CurrentCellAddress to update the dgv.CurrentRow.Index.

– TnTinMn
Mar 21 at 22:32













Setting CurrentCell worked just fine. Thank you TnTinMn

– GunnerFan420
Mar 22 at 14:20





Setting CurrentCell worked just fine. Thank you TnTinMn

– GunnerFan420
Mar 22 at 14:20












1 Answer
1






active

oldest

votes


















0














"Current" and "selected" do not mean the same thing. How could they, when multiple rows can be selected but there can only be one current row? The current row is the row that currently contains the caret and a selected row is one that is highlighted. If you want the row at index 2 to be the current row then you need to make a cell in that row the current cell, i.e. assign a cell in that row to the CurrentCell property.






share|improve this answer























  • Setting CurrentCell worked just fine. Thank you jmcilhinney

    – GunnerFan420
    Mar 22 at 14:21











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289857%2fdatagridview-rows-selected-not-updating-currentrow-index%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














"Current" and "selected" do not mean the same thing. How could they, when multiple rows can be selected but there can only be one current row? The current row is the row that currently contains the caret and a selected row is one that is highlighted. If you want the row at index 2 to be the current row then you need to make a cell in that row the current cell, i.e. assign a cell in that row to the CurrentCell property.






share|improve this answer























  • Setting CurrentCell worked just fine. Thank you jmcilhinney

    – GunnerFan420
    Mar 22 at 14:21















0














"Current" and "selected" do not mean the same thing. How could they, when multiple rows can be selected but there can only be one current row? The current row is the row that currently contains the caret and a selected row is one that is highlighted. If you want the row at index 2 to be the current row then you need to make a cell in that row the current cell, i.e. assign a cell in that row to the CurrentCell property.






share|improve this answer























  • Setting CurrentCell worked just fine. Thank you jmcilhinney

    – GunnerFan420
    Mar 22 at 14:21













0












0








0







"Current" and "selected" do not mean the same thing. How could they, when multiple rows can be selected but there can only be one current row? The current row is the row that currently contains the caret and a selected row is one that is highlighted. If you want the row at index 2 to be the current row then you need to make a cell in that row the current cell, i.e. assign a cell in that row to the CurrentCell property.






share|improve this answer













"Current" and "selected" do not mean the same thing. How could they, when multiple rows can be selected but there can only be one current row? The current row is the row that currently contains the caret and a selected row is one that is highlighted. If you want the row at index 2 to be the current row then you need to make a cell in that row the current cell, i.e. assign a cell in that row to the CurrentCell property.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 23:55









jmcilhinneyjmcilhinney

26.5k32033




26.5k32033












  • Setting CurrentCell worked just fine. Thank you jmcilhinney

    – GunnerFan420
    Mar 22 at 14:21

















  • Setting CurrentCell worked just fine. Thank you jmcilhinney

    – GunnerFan420
    Mar 22 at 14:21
















Setting CurrentCell worked just fine. Thank you jmcilhinney

– GunnerFan420
Mar 22 at 14:21





Setting CurrentCell worked just fine. Thank you jmcilhinney

– GunnerFan420
Mar 22 at 14:21



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55289857%2fdatagridview-rows-selected-not-updating-currentrow-index%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript