|
Private Sub ofdExcelReader_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ofdExcelReader.FileOk
Dim DataViewExcel As DataView
txtTempXls.Text = ofdExcelReader.FileName
DataViewExcel = FillDataSet()
If (DataViewExcel.Table.Rows.Count < 1) Then
MsgBox("This Sheet Is Empty. Please Select Another Sheet", MsgBoxStyle.OkOnly)
Else
dgvExcelColumn.DataSource = DataViewExcel
dgvExcelColumn.AutoResizeColumn(0)
dgvExcelColumn.AutoResizeColumn(1)
'Me.dgvExcelColumn.Columns(0).Visible = False
End If
End Sub
this the code tht i wrote to read the excel into the grid....i am using vs2005
|
|
|
|
|
Hi,
i am also using vs2005 and vb.net coding.
i am using a DataGridView and not a DataGrid!!!!
this is what i am doing and it works just fine....
***********************************************
dim dt as new datatable
dim data as new clsdata
dt = data.GetStockCodes()
me.dgView.datasource = dt
me.dgview.columns(0).visible = false ' where '0' = column index
me.dgview.columns(2).visible = false ' where '2' = column index
*************************************************
hope this helps
Anoop Brijmohun
|
|
|
|
|
Anoop i tried your code but dont know y is it not working for me???? i am gettig extra columns like TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME(in this column the values are the sheet names from the excel that i select) and yes its datagridview n not data grid...am sorry.....i want to remove these extra columns.....
|
|
|
|
|
Hi...
mmm....
no idea why not working for you dude,
try this.....
*******************************
Me.dgView.Columns.Remove("ColumnName")
*********************************
ALTERNATIVELY
instead of using a dataview
*****************************
Dim DataViewExcel As DataView
txtTempXls.Text = ofdExcelReader.FileName
DataViewExcel = FillDataSet()
*****************************
try using a datatable
*****************************
Dim DataViewExcel As new DataTable
txtTempXls.Text = ofdExcelReader.FileName
DataViewExcel = FillDataSet()
DataViewExcel.columns.remove("ColumnName")
*****************************************
thats all i can think of though....
the above works fine for me.....
anyway, hope you come right...i gotta go till tom.
Anoop
|
|
|
|
|
Setting a column's visibility to false should have worked. Might want to re-check your code or when it is being executed. Probably a timing issue.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
Sorry for the late reply.....thank you very much for th help....i used th following code to remove th extra columns
DataViewXls.Table.Columns.Remove("TABLE_CATALOG")
|
|
|
|
|
The best way to do this is to retrieve only the columns you need from the database. Outside of that, if you have a table that has more columns than you need to display, turn off the option that automatically creates columns in the DataGridView, then create your own DGV columns (which you should already be doing anyway, right?!), and map those columns to the ones in your DataTable.
|
|
|
|
|
Dave am using visual studio 2005 and am not able to find the property AutoGenarateColumns for the datagridview....can you help me on this.....thanks in advance...
|
|
|
|
|
Did you use the class name instead of the instance name?? This won't work:
DataGridView.AutoGenerateColumns
This does:
myDGV.AutoGenerateColumns = False
|
|
|
|
|
sorry for th late reply.......thanks for th help....i used th following code to remove th extra columns
DataViewXls.Table.Columns.Remove("TABLE_CATALOG")
|
|
|
|
|
Ok I have a picturebox being centered on my MDI Parent form. WHenever I open a child form of my MDI parent form the picturebox floats in front of the child form. I know that this is how MDI Parent forms are supposed to act. I have found that any control placed on an MDI parent form will always be in front of any child forms.
I already have a background image property set but need another image centered in the middle. I have the code for centering but need to figure out how to get this picbox to stay in the background. Since I already have a background image set this is not going to be the solution which seems to be the answer everyone gives for this question as I have found through searching the web.
Does anyone know a way to keep a picturebox (or any control for that matter) on an MDI parent form in the background when child forms are opened??? if you can solve this I will be in debt to you forever! PLEASE SOMEBODY HELP ME!!!!!
|
|
|
|
|
This is the expected behavior.
The MDI Parent has a control on it, called the MDIClient, that sits behind all other controls on the form. All MDI Child windows are rendered by the MDIClient control. Any controls you put on the MDI Parent form will sits "in front of" the MDIClient control.
It's possible to bring the MDIClient control to the front, but when you do this, it will cover the PictureBox control. You won't be able to see the picture you put in there.
The MDIClient control does have a BackgroundImage property, so you can setup a picture on it.
You can find out how to get a handle on the MDIClient control here[^].
|
|
|
|
|
Yes I even put in my message that I found out that this was the expected behavior. I also put that I already have a background image so I cant use that as a solution to my problem. I need a "workaround" for this. I take it there is no way you can think of to accomplish what I need to do??? Thank you for replying to my question tho. Im not trying to down your post or anything, it just didnt give me any information I didnt already know.
There has got to be a way to accomplish what I am trying to do. I am not advanced enough to figure it out tho. I am still pretty much a begginer at programming. I guess you could call me an "advanced-beginner". Not quite to the novice class yet... So please, all advanced programmers: HELP ME!!!!!
|
|
|
|
|
I'm not entirely sure what you're trying to do. That's why you got the description you did.
But, if you're trying to show two images as the background of the MDIClient area, you need to combine them as a single bitmap and set the BackgroundImage of the MDIClient to that new image. There is no other alternative.
|
|
|
|
|
I have a tooltip defined for a datagridview cell. It displays when I hover the mouse over the cell. I'd like however to update the contents of that tooltip when it displays. How can I best do that? Is there a tooltip display event? The mousehover event doesn't seem to really work in this regard.
Thanks
|
|
|
|
|
I think there is show and/or popup event. Not sure though
|
|
|
|
|
Or perhaps mousehover would work if I knew how to reset it once it fired once (without having to move the mouse outside of and then back into the DGV).
|
|
|
|
|
If I get what you're talking about doing, there isn't an event like you're talking about.
What you'd have to do is handle the DGV's CellMouseHover and probably CellMouseLeave events to interrogate the cell the mouse is over and set the ToolTip's Text property as the mouse moves.
|
|
|
|
|
OK, well that made the whole thing painfully obvious -- just set the tooltip on the cellmouseenter event. DOH!
Thanks
|
|
|
|
|
You can make updatable tooltips by making use of the following steps using Javascript.
For the first time, On mouse over event you can create a "DIV" control using "createElement" method with the respective text. Then, you can update the content of the "DIV" element innertext on mouse out event(you can hide this "DIV").
While creating the control make the "Control ID" uniform across all the cells, so that you don't need to recreate the control every time.
If it's already there you can just make the display property to 'block' or else create the control newly.
Hope this helps you.
Regards,
Vengat P
|
|
|
|
|
This won't work in a Windows Forms app, just web...
|
|
|
|
|
I'm writing a little app to save the clipboard to a file and then mail a link to it to selected recipients. For the saved file to be accessible by the recipients, I verify that the parent folder is shared.
However, if the share is on a local drive, I have to convert the full path to something like:
DriveID:\SomePath1\SharedFolderName\SomePath2\FileName.ext
and then to:
\\HostDNSname\ShareName\SomePath2\FileName.ext
where ShareName is the provider name for:
DriveID:\SomePath1\SharedFolderName
and SharedFolderName is the 'deepest' level share - i.e., it accounts for the possibility of SomePath1 including higher level shared folders.
I'm using the Win32_LogicalDisk ManagementClass and Win32_Share ManagementClass to obtain the info I need, but have not found an easy way to do the path conversion.
Before I dig into the implementation, I thought I'd check to see whether anyone has attempted this and whether they found an easy way to do this.
Comments would be appreciated...
emilG
"Dealing with failure is easy: Work hard to improve.
Success is also easy to handle: You've solved the wrong
problem. Work hard to improve." - Alan Perlis
|
|
|
|
|
What's so hard about removing the beginning of a string and replacing it with a workstation name?
|
|
|
|
|
Nothing hard, once I have the string. For instance, if I have the following shares on my machine:
D:\ with a share name of "D$"
and:
D:\MyPrivateDownloads\Tools\ABCtool\ with a share name of "ABCdownload"
plus a bunch of other shares on the same drive, with the file stored in:
D:\MyPrivateDownloads\Tools\ABCtool\Docs\UserManual\UsingABCinfo.pdf
I want to send the following link:
\\myMachineName\ABCdownload\Docs\UserManual\UsingABCinfo.pdf
and not:
\\myMachineName\D$\MyPrivateDownloads\Tools\ABCtool\Docs\UserManual\UsingABCinfo.pdf
So, although it is not rocket science to accomplish this, I was wondering if there was an easy way of accomplishing it [via some framework class maybe].
emilG
"Dealing with failure is easy: Work hard to improve.
Success is also easy to handle: You've solved the wrong
problem. Work hard to improve." - Alan Perlis
|
|
|
|
|
1. Dave is right on this. You're making this to difficult. Do something like:
replace("D:\MyPrivateDownloads\Tools\ABCtool\Docs\UserManual\UsingABCinfo.pdf","D:\MyPrivateDownloads\Tools", "\\" & environment.GetEnvironmentVariable("ComputerName"))
Keep it simple.
egottwald wrote: D:\ with a share name of "D$"
2. C$ and D$ are admin shares and shouldn't be used. If it were me, I'd disable them entirely because someone could just access all the dirs/files regardless of what you intended (with \\myMachineName\D$).
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|