Pictures on the toolbar

genu

Well-known member
Joined
Jun 9, 2005
Messages
94
Programming Experience
1-3
hi, im trying to get pictures on the toolbar...and for some readon they are not showing right...I made them gifs so I can have them be transparent but they have a blue line around them like in the screenshot
 

Attachments

  • sc.jpg
    sc.jpg
    14.1 KB · Views: 223
o sorry...well.. what could be the problem? or what is the proper format to use for toolbar icons for that matter.
 
hey jmcilhinney I got it to add items to the datagrid but here is another problem I ran into: when clicking on a cell on the datagrid...it makes it so that the user can change the contents of the cell by highliting it and ppl could just change that. I didnt want that so I made the "read Only" property in the datagrid control to "TRUE", but now when they click on a cell it just selects the contents just like before they just cant edit it.

HOW do I make it so that when they click any cell..it selects the whole row not just that cell?
 
I'm actually not greatly experienced with DataGrids myself. Most of what I know is from reading rather than doing. The DataGrid class has a CurrentRowIndex property that you can set or a Select method that you can call. I'm not sure if using either of these will actually highlight the whole row if a cell is already selected, but I'd say that they are your best bet. It may be that you can only select a row by clicking the left hand border of the grid. When the user clicks a cell, you can get the row number from CurrentCell.RowNumber. You may also be able to use the HitTest method in the click event handler.
 
ok JM I got it to select the entire row when they click on a cell, but now how do I make it that when they click on a cell and the cell contents is highlited to just end the editing. i hope that makes sense because now when they click on a cell the whole row is selected but that cell is still being highlited like it can be edited like before....Im almost there.
 
here is the code I used:

PHP:
 Private Sub table_main_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles table_main.CurrentCellChanged
        table_main.Select(table_main.CurrentCell.RowNumber)
        table_main.     'WHAT goes here to deselect the editing on that cell
    End Sub
 
I can't say for sure but I'll give you my three best guesses:

table_main.CurrentCell = Nothing

or

table_main.EndEdit()

or

do something (I don't know what) with table styles or column styles to prevent the appearance of editing in the first place.
 
LOL...well I tried your first guess...and this gets part of the job done. clicking on a cell selects the whole row with now problem just like its supposed to...but for a reason I dont understand is that the first row is selected and the first cell in that row is up for editing...no matter what row I click that first row and first cell is selected...its weird how they are connected...i dont understant...so everytime I click on a cell...that row is selected as well as the first row...so two rows at once are always selected with the table_main.currentcell = nothing
 
Try this:
VB.NET:
Dim selectedRow As Integer = table_main.CurrentCell.RowNumber

table_main.CurrentCell = Nothing
table_main.CurrentRowIndex = selectedRow

Edit:
or, if that doesn't work
VB.NET:
Dim selectedRow As Integer = table_main.CurrentCell.RowNumber
 
 table_main.CurrentCell = Nothing
 table_main.Select(selectedRow)
 
genu said:
that actually gave me error
What error? Which line? People saying they get an error without further explanation is a pet peeve of mine.

Did you see the edit to my previous post? Same error?
 
genu said:
here is the source...maybe u can try some things
Sorry. I'm very not big on downloading entire projects. To be honest, I've never used a DataGrid in a production app, so all I know is from reading and experimentation. I suggest you look at the member list for the DataGrid class and try some things yourself. Also, check out the DataGridTableStyle and DataGridColumnStyle classes. They allow you to modify DataGrid appearance and behaviour although, once again, I've never used them myself.
 
here is the error that I got before:

An unhandled exception of type 'System.StackOverflowException' occurred in system.windows.forms.dll

and it highlited: table_main.CurrentCell = Nothing

FROM THIS

table_main.Select(table_main.CurrentCell.RowNumber)
Dim selectedRow As Integer = table_main.CurrentCell.RowNumber

table_main.CurrentCell = Nothing
table_main.CurrentRowIndex = selectedRow
 
genu said:
here is the error that I got before:

An unhandled exception of type 'System.StackOverflowException' occurred in system.windows.forms.dll

and it highlited: table_main.CurrentCell = Nothing

FROM THIS

table_main.Select(table_main.CurrentCell.RowNumber)
Dim selectedRow As Integer = table_main.CurrentCell.RowNumber

table_main.CurrentCell = Nothing
table_main.CurrentRowIndex = selectedRow
You would remove the first line, i.e. the call to Select. The last line is supposed to be setting the correct row so you don't need to do it twice. This may not get rid of the error though. This is a little bit of a hack but it might work:
VB.NET:
'Get the index of the current row.
Dim selectedRowIndex As Integer = table_main.CurrenRowIndex

'Prevent each change being seen as it is made.
table_main.SuspendLayout()

'Select the first row, which should remove selection from the cell that was clicked.
table_main.CurrentRowIndex = 0

'Select the previously selected row, hopefully without selecting the cell again.
table_main.Select(selectedRowIndex)

'Apply all changes together.
table_main.ResumeLayout()
Obviously, this will not work for the first row, even if it does for others. You would need to test to see whether the selected row was index zero and, if so, toggle selection to another row momentarily instead.
 
VB.NET:
'Get the index of the current row.
Dim selectedRowIndex As Integer = table_main.CurrenRowIndex

'Prevent each change being seen as it is made.
table_main.SuspendLayout()

'Select the first row, which should remove selection from the cell that was clicked.
table_main.CurrentRowIndex = 0

'Select the previously selected row, hopefully without selecting the cell again.
table_main.Select(selectedRowIndex)

'Apply all changes together.
table_main.ResumeLayout()

what this does is the same results as before ( just edidint the first row cells) but now, when I click on the second column on any row, the cell on that column in the first row becomes editable, so basically the editable cell in the first column coresponds to which ever cell I click on on the other rows.
 
Back
Top