Question How to block on 1 of DataGridView rows ?

capedech

Well-known member
Joined
Oct 29, 2008
Messages
62
Programming Experience
Beginner
Hi,
I have a question.
If we're clicking 1 of DataGridView rows, there will be 1 block line of row in the DataGridView.
I want to do that but with a coding.
I tried :
DataGridView.Focus
DataGridView.SelectedItem.Selected = 10

but can't do the trick.

Does anyone know how to do that ?

Thanks for the answer.

Regards,

nb. Please forgive my bad english.
 
So you want to select a row in the DataGridView programatically?

VB.NET:
Me.DataGridView1.Rows(10).Selected = True
 
Thank you. It help's a lot.

I more question.
Can we do the same thing to ListView ?
I mean, select a row in List View programatically ?
 
VB.NET:
Me.ListView1.Items(10).Selected = True
For full row selection you have to turn on the ListView property FullRowSelect.
 
I didn't notice you were asking about "block" before, you asked "select a row in List View programatically ?". What do you mean by "block"? If you mean "freeze" then you can set Frozen property of row in DataGridView, but there is no such functionality in ListView.
 
What I mean by block is.. I don't know how to explain in english. -.-'
Like, when u want to copy some text, u need to block the text that u want to copy, then press [Ctrl +C] for copy, then press [Ctrl + V] for paste.

Maybe if I give u some code u can understand better.
Here's some code in VB to block TextBox
VB.NET:
1. SendKeys "{home}+{end}"
2. selText(txtPass.text,0,len(txtPass)) ??
3. Text1.SetFocus
   Text1.SelStart = 0
   Text1.SelLength = Len(Text1.Text)
U can choose from 3 of those code to block a TextBox.
 
I have no idea what you're talking about, sorry. Later, dude :)
 
By "block" he means "select/highlight for the purposes of copy/paste"

i.e. point to the A with your mouse, hold down the left mouse button and move to Z:

-----ABCDEFGHIJKLMNOPRSTUVWXYZ-----


You have "blocked" the alphabet ;)
 
@John
just select the row, but didn't block the line.

Please explain as best you can, the difference between "select" and "block" - to me, what you call "blocking" i call "selecting" but it is clear that my "select" and your "select" are different things. Please explain this difference
 
Please explain as best you can, the difference between "select" and "block" - to me, what you call "blocking" i call "selecting" but it is clear that my "select" and your "select" are different things. Please explain this difference

Yes, u are correct. Thanks for helping me explaining it ^.^.
It's highlight. I want the row highlighted programaticaly.
 
When you browsed through the Listview members in help you missed the HideSelection property.
 
Indeed, John is right. If HideSelection is true, then the ListView will not highlight a row if it does not have the focus. Because you want your LV to show a highlight even when it does not have the focus, you must set HideSelection to false.
 
Back
Top