ScriptSpot

Forum topic · General Scripting

DESELECT row in datagridview by defolt

By artrender.info · 2013-02-25

Description


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

--doesn't help

table.CurrentRow.Selection = False

--gives error

Comments (8)

THANKS A LOT

artrender.info · 2013-02-28

this code worked for me:


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

STILL ERROR

artrender.info · 2013-02-27

Even with counter = 0

Attachments

change all (counter) to [counter]

Anubis · 2013-02-28

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.

I didn't use uny value

artrender.info · 2013-02-26

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

integer

Anubis · 2013-02-26

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

counter = 0

Thx Anubis!

artrender.info · 2013-02-25



		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

probably something missed

Anubis · 2013-02-25

what you used for "counter" value?

counter = ?.. --some integer

Anubis · 2013-02-25

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