hello there,
I'm using a vb.net and using for displaying a record into system.windows.forms.datagridview "datagridview".. my problem is i want to set unfocus the grid "remove the highlighted cell there." i just want to remove the highlighted cell on load and put it on clicking the grid. is this possible?? please help.
Thanks in advance.
Loading
Leslie ParbaPosted Aug 14, 2008, 11:17 AM
Ryan AlfordPosted Aug 14, 2008, 10:14 AM
ex...
If DataGridView1.Rows.Count > 0 Then
DataGridView1.SelectedRows(0).Selected = false
Leslie ParbaPosted Aug 13, 2008, 7:01 PM
AlanPosted Aug 13, 2008, 6:52 PM
Leslie ParbaPosted Aug 13, 2008, 6:33 PM
AlanPosted Aug 13, 2008, 6:20 PM
Assuming you're calling the LoadToGrid() method from Form_Load, the error message suggests that no rows are selected at that stage. So the first row must get selected just after the form loads.
If that's the case, then I think I'd try handling the Form's GotFocus event (or possibly the Activated event) instead and put that line in the eventhandler:
Private Sub Form1_GotFocus(sender as Object, e as EventArgs) _
Handles Form1.GotFocus
grd1.SelectedRows(0).Selected = False
End Sub
From memory, I don't think this event shows up in the VS Properties box so you'll just have to paste it in.
Leslie ParbaPosted Aug 13, 2008, 5:39 PM
Parameter name: index" this is my code.
Private Sub LoadToGrid()
Dim ConnString As String = CurrentFacade.OnlineConnectionString
Dim SQLString As String = "SELECT ID, LabelDesc, LengthDescription, FontSize, XCoor, YCoor, FontName, FontColor, case TextJustication when 1 then 'Left' when 2 then 'Center' when 3 then 'Right' end as TextJustification, BlacklistDictionary FROM CustomField_C"
Dim SqlDataAdapter1 As New SqlDataAdapter(SQLString, ConnString)
Dim DataSet1 As New DataSet()
SqlDataAdapter1.Fill(DataSet1, "CustomField_c")
grd1.DataSource = DataSet1.Tables("CustomField_c")
// this is to hide the first colurm. which is the ID
grd1.Columns(0).Visible = False
grd1.SelectedRows(0).Selected = False
End Sub
AlanPosted Aug 13, 2008, 4:29 PM
If DataGridView1 is your DGV, then try putting this line in your Form1_Load:
DataGridView1.SelectedRows(0).Selected = False