Avatar billede iblarsen Praktikant
24. november 2005 - 06:53 Der er 4 kommentarer og
1 løsning

Sætte row position i et datagridview

Jeg vil gerne kunne bestemme hvilken "row" som skal være valgt, når en winform med et datagridview (.Net Framework 2.0) åbnes.

Lad os sige jeg har et datagridview med følgende kolonner Fornavn, Efternavn, Telefonnr.

Hvordan kan jeg bestemme at at det er linien med Telefonnr = 12345678 som skal være valgt.
Avatar billede dr_chaos Nybegynder
24. november 2005 - 08:18 #1
fra msn:
Programmatic Selection

The current selection mode restricts the behavior of programmatic selection as well as user selection. You can change the current selection programmatically by setting the Selected property of any cells, rows, or columns present in the DataGridView control. You can also select all cells in the control through the SelectAll method, depending on the selection mode. To clear the selection, use the ClearSelection method.

If the MultiSelect property is set to true, you can add DataGridView elements to or remove them from the selection by changing the Selected property of the element. Otherwise, setting the Selected property to true for one element automatically removes other elements from the selection.

Note that changing the value of the CurrentCell property does not alter the current selection.

You can retrieve a collection of the currently selected cells, rows, or columns through the SelectedCells, SelectedRows, and SelectedColumns properties of the DataGridView control. Accessing these properties is inefficient when every cell in the control is selected. To avoid a performance penalty in this case, use the AreAllCellsSelected method first. Additionally, accessing these collections to determine the number of selected cells, rows, or columns can be inefficient. Instead, you should use the GetCellCount, GetRowCount, or GetColumnCount method, passing in the Selected value.


http://66.249.93.104/search?q=cache:LwpFpgetY-wJ:winfx.msdn.microsoft.com/library/en-us/dv_fxmclictl/html/a3ebfd3d-0525-479d-9d96-d9e017289b36.asp+set+selected+row+datagridview+&hl=da
Avatar billede iblarsen Praktikant
24. november 2005 - 08:26 #2
Og hvad får du ud af det? - det virker for mig som om det ikke direkte er muligt???
Avatar billede dr_chaos Nybegynder
24. november 2005 - 08:29 #3
hvis du finder ud af hvilken row eller cell der indeholder Telefonnr = 12345678
kan du sætte selected til true på den row.
Avatar billede iblarsen Praktikant
24. november 2005 - 08:56 #4
Det var lige hvad jeg skulle bruge - tusind tak!
Smider du lige et svar.
Avatar billede dr_chaos Nybegynder
24. november 2005 - 08:57 #5
np :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB

Csis Security Group A/S

Sales Executive

Netcompany A/S

Network Engineer

Capgemini Danmark A/S

Finance Lead (SAP)

Akademikernes A-kasse

AI Product Owner