ScriptSpot home

Forum topic · General Scripting

DESELECT row in datagridview by defolt

By artrender · 2013-02-25

Description


table.rows.clear()
table.ClearSelection
table.CurrentCell = Nothing

--doesn't help

table.CurrentRow.Selection = False

--gives error

Comments (8)
artrender

THANKS A LOT

this code worked for me:


table.rows.item[0].cells.item[0].Selected = False
artrender

STILL ERROR

Even with counter = 0

Attachments
Reply to artrender
Panayot Karabakalov

change all (counter) to [counter]

Yep, I think we miss the syntax conversion :)

In DotNet languages call to item by index is surrounded with round brackets "()", for example:

table.Rows(counter).Index

, while in MaxScript with square brackets "[]", like:

table.Rows[counter].Index

.

So, fix that too (in all places), and lets hope there no more chunks.

artrender

I didn't use uny value

I have just used your code! I don't what value should I use for counter!

Reply to artrender
Panayot Karabakalov

integer

the "counter" in the example code serve as variable, it s'd be integer value, for example 0.

counter = 0
artrender

Thx Anubis!



		table.SelectionMode = (dotNetClass "System.Windows.Forms.DataGridViewSelectionMode").FullRowSelect
		table.RowHeadersVisible = false

		table.FirstDisplayedScrollingRowIndex = table.Rows(counter).Index
		table.Refresh() -- refresh after scroll
		table.CurrentCell = table.Rows(counter).Cells(1)
		table.Rows(counter).Selected = True -- use #Selected with Boolean

I get error


Type error: Call needs function or class, got:

dotNetObject:System.Windows.Forms.DataGridViewRowCollection

table.CurrentRow.Selected = False 

gives -- Unknown property: "selected" in undefined

Reply to artrender
Panayot Karabakalov

probably something missed

what you used for "counter" value?

counter = ?.. --some integer
Panayot Karabakalov

I not use DataGridView so take my words as friendly attempt to help. What I did is just quick search.

I'm not sure if there exist #Selection property for CurrentRow, but found that CurrentCell cannnot be set to Nothing. You s'd set that property to valid Cell which s'd be visible as well, i.e. need to scroll if necessary. Shortly, something like this:

--counter = ...
--DVG.ClearSelection()
DGV.FirstDisplayedScrollingRowIndex = DGV.Rows(counter).Index
DGV.Refresh() -- refresh after scroll
DGV.CurrentCell = DGV.Rows(counter).Cells(1)
DGV.Rows(counter).Selected = True -- use #Selected with Boolean

I hope this help