|
thanks but DialogResult.OK is only hit if the file does not exist and the over write dialog is not displayed. However when the overwrite dialog is displayed the buttons displayed are Yes/No and after accepting to overwrite I cant hit DialogResult.OK or DialogResult.Yes
|
|
|
|
|
The following code works fine for me, even if the file exists and I press Yes to the Overwrite Prompt.
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then<br />
MsgBox("Save Done")<br />
End If
Which version of Visual Basic are you using? I suppose if worse comes to worse, you could disable the Overwrite Prompt property and do a manual check whether the file exists or not, IO.File.Exists(SaveFileDialog.FileName) , and then proceed from there.
|
|
|
|
|
Hi,
IMO you worry too much.
this is the behavior I expect: when you choose the destination file and it
- either does not exist
- or it exists but you allow for an overwrite,
then the SaveFileDialog will return a go-ahead result (I think it's OK),
and your code should open the file for writing in such a way that it does not
matter whether it already exists or not, such as:
- File.Create() which creates new, or overwrites without appending
- File.CreateText() which creates new, or overwrites without appending
The above would work fine, except in one special case, that's when the file already exists
but is set to read-only (not checked by SaveFileDialog).
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
for the existing MenuStrip-Item I want to create an appropriate ToolStrip with identical buttons.
But how can I access the existing click-events?
I cannot "addhandler mmi.click, adressof mi.click" and
"adressof mi.onclick" also fails because it's protected.
In c# I must add the handlers manually, so I know them, but in vb
it's hidden...
<br />
For Each Mi As ToolStripItem In FileMenu.DropDownItems<br />
If TypeOf (Mi) Is ToolStripMenuItem Then<br />
Dim mmi As New ToolStripButton<br />
mmi.Text = ""<br />
mmi.Image = Mi.Image<br />
mmi.ToolTipText = Mi.Text<br />
<br />
addhandler mmi.click, "get the handler of the mi.click-event"<br />
<br />
tsProgramm.Items.Add(mmi)<br />
ElseIf TypeOf (Mi) Is ToolStripSeparator Then<br />
Dim mmi As New ToolStripSeparator<br />
tsProgramm.Items.Add(mmi)<br />
Else<br />
<br />
End If<br />
Next<br />
Thanks in advance
Chris
|
|
|
|
|
Where is this existing click handler coming from?
If you haven't created and assigned one, it doesn't yet exist.
If you have, then keep a reference to the delegate for later assignment.
If you're refering to one used by the control internally, it maybe accessible via reflection - but that would be very poor design.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
MidwestLimey wrote: Where is this existing click handler coming from?
I wrote it, every menuitem has a eg fileopen_click(sender, e) handles fileopen.click.
MidwestLimey wrote: If you have, then keep a reference to the delegate for later assignment.
Isn't there a get-the-address-of-the-onclick-event--function in the .net-jungle?
MidwestLimey wrote: If you're refering to one used by the control internally, it maybe accessible via reflection - but that would be very poor design.
Ugly, yes...
Fastest way would be coding out every menuitem, but that's not very genious.
Thanks for your answer
Chris
|
|
|
|
|
I got a solution, but with that I have to declare all Menuitem_Click-Subs as Public and I have to set an InitFlag into them to supress invocation, because CallByName calls the event...
For Each Mi As ToolStripItem In FileMenu.DropDownItems<br />
If TypeOf (Mi) Is ToolStripMenuItem Then<br />
Dim mmi As New ToolStripButton<br />
mmi.Text = ""<br />
mmi.Image = Mi.Image<br />
mmi.ToolTipText = Mi.Text<br />
Dim pArray() As Object = {Mi, New System.EventArgs}<br />
<br />
Dim delegateMn As System.EventHandler = CType(CallByName(Me, Mi.Name & "_Click", CallType.Method), System.EventHandler)<br />
AddHandler mmi.Click, delegateMn<br />
<br />
tsProgramm.Items.Add(mmi)<br />
ElseIf TypeOf (Mi) Is ToolStripSeparator Then<br />
Dim mmi As New ToolStripSeparator<br />
tsProgramm.Items.Add(mmi)<br />
Else<br />
<br />
End If<br />
Next
|
|
|
|
|
Why not declare the delegate ahead of time and then assign to each item's event?
Dim myDelegate As EventHandler = AddressOf MenuItem_Click
Where MenuItem_Click is a generic event handler for tool strip menu items.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Then I have to write 15 or more new delegates? Right?
The aim was to add a toolstrip to the existing menustrip to act like a buddy.
The new toolstrips get all properties from the existing menustrips and share the same events (there are more than 1 menustrip in the mdi).
So I thought I could put some code-lines into a loop....
|
|
|
|
|
If I understand what you're trying to do (bear with me, I'm slow today!), then wouldn't it be easier to add a general event handler to the buddy strip buttons that calls PerformClick on the appropriate menu buttons? You could maintain context via either the Tag property or a dictionary.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
That would be a very good solution. I'll try it out.
Thanks
Chris
|
|
|
|
|
Hi
Don't think this is VB.NET but... How do I loop thru each non-empty row in Excel VBA?
<br />
For Each oSheet In Worksheets<br />
For Each oRw In oSheet.Rows<br />
IsRowEmpty(oRw) ' Do I need to code IsRowEmpty?<br />
Next oRw<br />
Next oSheet
Thanks
devy
|
|
|
|
|
devvvy wrote: IsRowEmpty(oRw) ' Do I need to code IsRowEmpty?
Yes, because "empty" can have any number of meanings. Does empty mean that there are no values?, no formulas?, no formatting?, ... You have to code this to test to see if the row meets your specification of "empty".
|
|
|
|
|
Okay you are right. But then comes another technical problem...
say I selected three rows on worksheet.
Worksheets("Data").ActiveCell.Row only gives you ONE of the three selected rows.
How do I retrieves all three selected rows?
Thanks!
devy
|
|
|
|
|
Just found solution thanks anyway:
<br />
Dim rngActive As Excel.Range<br />
Set rngActive = Selection<br />
For Each oRecord In rngActive.Rows<br />
... do something ...<br />
Next oRecord<br />
devy
|
|
|
|
|
how to i save time n date in to database....i just know the code for show time n date..
datetimepicker.value=datetimepicker.now
how can i store it into database....can i use the update same as textbox and combo box..example like receipt there is date on top...when end of month i need retrieve from 1/1/08 until 31/1/08 how i can write the code
to update the latest date,and i stil can retrieve previous date...
i try below this but can't ,can some one teach me or give some idea..
"Me.TimeTableAdapter.Update(Me.timeDataSet.timeIn)"
can any one help me up..thanks in advanced....
this problem should be solved using vb.net 2005 and sql server for database
kevin
modified on Monday, March 31, 2008 10:10 AM
|
|
|
|
|
If you want to put data into an SQL database, you'll want to look at the INSERT command and it's uses. If you want to select data from an SQL database, you'll want to look at the SELECT command as well.
Whenever you insert a row into an SQL database, it will remain there unless you delete it, so running SELECT commands in order to handle data will not remove anything.
Here's a helpful link that explains a lot about SQL queries.
http://www.w3schools.com/sql/[^]
|
|
|
|
|
I'm geting an error message saying that "no value given for one or more required parameters"
e.fullPath is correct and the feild names are identical to the ones in excel apart from 'reason mobilised'. I have put it in [] because of the space. I would do a select * but there are many other feilds that don't need to be read at this stage.
Here's the code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" _
& "data source=" & e.FullPath & "; " & "Extended Properties=Excel 8.0;")
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select INCIDENT_NO," _
& "INC_TYPE,ESTATE,TOWN,COUNTY,NAME_AND_PHONE_NO,CALLSIGN,[REASON MOBILISED]," _
& "MOBS_DT,MTI,INATT,STOP,MAV,AHS,OPERATOR_INFO from [sheet1$]", MyConnection)
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
MyConnection.Close()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
As always any help you can provide will be appreciated.
Colonel-yum-yum
|
|
|
|
|
On what line does the error occur??
It looks like you missing a couple of parameters from the connection string, specifically HDR and IMEX.
HDR tells the provider that the first row of the sheet container header names for each column. IMEX tells it the any columns that are determined to have mixed type data, some rows as numbers, some as text, should be treated as a text column.
Also, at the end of the SQL statement, there is a FROM clause. Make sure the name specified (Sheet1 in this example) matches the name of the sheet in your Excel workbook. It should be the sheet name with a $ appended to it.
Imports System.Data.OleDb
.
.
.
If File.Exists(e.FullPath) Then
Dim connStr As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;HDR=Yes;IMEX=1", e.FullPath)
Dim conn As New OleDbConnection(connStr)
Dim ds As New System.Data.DataSet
Dim comm As New OleDbDataAdapter("SELECT INCIDENT_NO,INC_TYPE,ESTATE,TOWN,COUNTY,NAME_AND_PHONE_NO,CALLSIGN,[REASON MOBILISED]," & _
"MOBS_DT,MTI,INATT,STOP,MAV,AHS,OPERATOR_INFO FROM [Sheet1$]", conn)
comm.Fill(ds)
End If
|
|
|
|
|
Hi all, I have been attempting sending HTML formated emails with Inline images. the emails apear to be sent OK (no exceptions) however the email is 'lost' in space, My guess is that it is being blocked by the hosting/ISP company, when I send HTML mail without images - the email is sent and received fine, here is a sample code as I use it, (I also tried the AlternateView option with the same result)
Dim EM As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage(txtFrom.Text, txtTo.Text)
Dim A As System.Net.Mail.Attachment = New System.Net.Mail.Attachment(txtImagePath.Text)
Dim RGen As Random = New Random()
A.ContentId = RGen.Next(100000, 9999999).ToString()
EM.Attachments.Add(A)
EM.Subject = txtSubject.Text
EM.Body = "<body>" + txtBody.Text + "<br><img src='cid:" + A.ContentId +"'></body>"
EM.IsBodyHtml = True
Dim SC As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient(txtSMTPServer.Text)
SC.Send(EM)
Any ideas how to solve this issue?
|
|
|
|
|
yaronbo wrote: My guess is that it is being blocked by the hosting/ISP company,
Probably true.
yaronbo wrote: Any ideas how to solve this issue?
Contact the ISP to see what they're blocking. It's possible you can't get around this at all because you're using a technique commonly used by spammers to try to get past spam filters.
|
|
|
|
|
I want to align DatagridView header to right. How can do this?
Gurudatta B. Shelke
|
|
|
|
|
hi,
select "ColumnHeaderDefaultCellStyle" property and click on ellipse button . this open a new window.
From this window you can select different property which is apply to Each Column Header of datagridview.
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Thanx Rupesh..
But my requirement is little bit different. 1st columns header should be left aligned and all others headers should be right aligned. I think i need to do it dynamically but how? can u tel me?
Gurudatta B. Shelke
|
|
|
|
|
try this:
dgv.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
the column at index 0 will be changed
hope it will help
edited :
oopppsss.... i posted code in C#, try to convert it
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|