|
No! You create the DataGrid columns manually and specify which columns they map to in the data source.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I am using the following code in codebehind file for creating a saveAs dialog box in webApplication in VB.net.
Dim filename As String = Session("DateTimeStampZip")
Dim fullPath As String = Server.MapPath(ConfigurationSettings.AppSettings("ServerDownload")) & "\" & filename
Dim dataStream As FileStream = New FileStream(fullPath,System.IO.FileMode.Open)
Dim fileLength As Integer = System.Convert.ToInt32(dataStream.Length)
dataStream.Close()
dataStream = Nothing
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & filename)
Response.AppendHeader("Content-length", fileLength.ToString())
Response.WriteFile(fullPath)
Response.End
My problem is that when I run the above code, I am getting a saveAs DialogBox with (checkbox:Always ask before opening this type of file.) shown in disabled mode..
With disabled I mean, in non-editable mode i.e; I am not able to check or uncheck the box.
When i click on open button in the box, same box pops up second time with the checkbox in enabled mode. Now i am able to open the file.
I want this saveAs dialogBox with the checkbox in enabled mode when I run the code first time and not after I click on open button in the dialog box.
Can anyone workout a solution to my problem..
PLease its urgent...
or any other way to create the dialog box using code in vb.net...
-- modified at 5:57 Friday 29th September, 2006
|
|
|
|
|
This is a question best asked in the ASP.NET[^] Forum.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I haven't posted a question before so I hope that this is the right forum.
I am developing a windows app in vb.net (2002) that I want to have an xp theme. I have read quite a few web articles describing the process for incorporating this and have indeed been successful at getting my .exe file to run with an xp theme. However, I have not been able to deploy the application with an xp theme.
My progress so far: I built the assembly manifest, given it the right name, called it “RT_MANIFEST” and an ID of 1. I then added it into the .exe file located in my ‘release’ folder manually, and when I then execute the .exe it works fine. I know that I have to manually add the manifest every time I build the project.
When I then come to deploy the app it does not keep the xp theme, even when I test run it on an xp PC set up to run xp style. I am not rebuilding the app project, just the deployment project so I don’t think a rebuild is the reason.
I have tried embedding the manifest into the .exe located in the ‘bin’ directory, but when I try to run this .exe I get an error message saying that the assembly is incorrect.
Any help would be really appreciated as I am completely stumped.
Thanks,
Ash
ash
|
|
|
|
|
I'm messing about a bit with Enums and combining them via (bitwise) OR and AND so I can assign multiple values to the Enum-types, but I am having some conceptual problems. I noticed in the msdn documentation that there was a <Flags()> attribute which could be set to your enum.
If I look at the msdn for <Flags()> it states: Indicates that an enumeration can be treated as a bit field; that is, a set of flags.
However my code seems to be indifferent to whether i assign <Flags()> to my Enum or not, hence my confusion? It seems to be able to handle both the OR and the AND with and without <Flags()>.
Can anybody give a quick explanation or point me to an article/ressource which explains this?
Thanks in advance
---------------------------
127.0.0.1 - Sweet 127.0.0.1
-- modified at 4:13 Friday 29th September, 2006
forgot to ignore html tags
|
|
|
|
|
Alsvha wrote: However my code seems to be indifferent to whether i assign <flags()> to my Enum or not,
It would help if we could see your code and what you're trying to do!
Combining flags is always done with an OR, not an AND. To check to see if a bit is turned on, you use AND:
Public Class Form1
<Flags()> Public Enum AccessOptions As Byte
None = 0
Read = 1
Write = 2
Delete = 4
Query = 8
Sync = 16
End Enum
Private Sub Button1_Click(blah, blah) Handles Button1.Click
Dim MyOptions As AccessOptions
' Turn on multiple options
MyOptions = AccessOptions.Read Or AccessOptions.Write Or AccessOptions.Sync
' Now check for each option being turned on. There are a few different ways
' of doing this!
Debug.WriteLine("None : " & (MyOptions = AccessOptions.None) )
Debug.WriteLine("Read : " & ((MyOptions And AccessOptions.Read) > 0) )
Debug.WriteLine("Write : " & ((MyOptions And AccessOptions.Write) > 0) )
Debug.WriteLine("Delete: " & ((MyOptions And AccessOptions.Delete) > 0) )
Debug.WriteLine("Query : " & ((MyOptions And AccessOptions.Query) = AccessOptions.Query) )
Debug.WriteLine("Sync : " & ((MyOptions And AccessOptions.Sync) = AccessOptions.Sync) )
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hey.
Thanks for the reply, but my issue is that it doesn't seem to matter if I use the "<Flags()>" or not:
<Flags()> Public Enum AccessOptions As Byte
None = 0
Read = 1
Write = 2
Delete = 4
Query = 8
Sync = 16
End Enum
seems to work like
Public Enum AccessOptions As Byte
None = 0
Read = 1
Write = 2
Delete = 4
Query = 8
Sync = 16
End Enum
for my bitwise comparison and funtionality. Thus me being somewhat puzzled.
---------------------------
127.0.0.1 - Sweet 127.0.0.1
|
|
|
|
|
How do you represent both Read and Write allowed in your second example?
|
|
|
|
|
I have made this example to mess about with it, which was where I found this issue: (please ignore bad naming as it is just a test project )
I have this enum:
Public Enum MyType As Integer<br />
TypeA = 1<br />
TypeB = 2<br />
TypeC = 4<br />
TypeD = 8<br />
TypeE = 16<br />
End Enum
(withouth <Flags()> )
I then "OR" some choices together and place them in a variable of the type of MyType.
This then results in some interger value depending on the choices.
Then I can check if a type is added to my object:
Dim result As MyType = mEnuType And examineType<br />
Return result = examineType
where mEnuType is the combined type variable and examineType is the one I try to check if contains.
I can remove added types by using XOR and all that, and all seems to work flawless. Withouth using the <Flags()> with my Enum, hence my confusion.
If I read the documentation (msdn) for <Flags()> it seems to indicate that I need it to do these bitwise functionalities, however this testing seems to indicate I do not, and I can't figure out what I am doing wrong?
---------------------------
127.0.0.1 - Sweet 127.0.0.1
|
|
|
|
|
Hi All,
Can anyone give me some advice how to pass the value from Form2 to Form1? For my project, user will click on the button at Form1 then Form2 will show, after that user will double click on the record at listview in Form2 and then Form2 will close, then the record select by user at Form2 will pass back to the Form1 and display at text box. How should I do for this situation?
|
|
|
|
|
i'm not in front of pc with visual studio, but here's some pointers to get you in the right direction....
if you have a module in your solution...
declare a public variable to store the data you want.
assign the listview item to the variable,close the form and show form2, then on form load event give the textbox .text property the value of the variable
|
|
|
|
|
If you want to write bad code, use a global variable. Otherwise, you should set up a delegate in form2, and hook it to a method in form1. Then, Form2 can call code in Form1 whenever it wants to pass a value.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I find that an interesting statement. Why would you consider using a global variable "bad code" as opposed to using a delegate?
|
|
|
|
|
Because it's a quick and dirty fix that breaks encapsulation. I know in VB6 such things were common, but in OO programming, it's not how things are done.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i haven't got any problems with such type of coding. i know what delegates are, i didn't replied, instructing him to use it, because i didn't remembered it.that way was the first one that came to my mind
|
|
|
|
|
I am relatively new to the .net frmework, but i LOVE IT. I was die-hard to upgrade from vb6, but I am glad I did.
Here is my problem. I am useing visual studio (vb.net) 2005. In my app, I use an API call to retireive a list of file object handles from a portable media device useing the Media Transport Protocol. ( I know what the handles of the files actually are becuase I use the direct MTP tool to show me what they are.) Here is API call I use:
Sub GetObjectHandles(ByVal StorageId As UInteger, ByVal FormatCode As MtpLib.MTP_FORMATCODE, ByVal ParentObjectHandle As UInteger, ByRef pcelt As Integer, _
ByVal ppObjectHandles As System.IntPtr, ByRef pResponseCode As MtpLib.MTP_RESPONSECODE)
And here is how i use it:
<code>
'Namespace
Imports MtpLib
Imports System.Runtime.InteropServices ' I added for marshaling
Public MTP AsNew MtpLib.WindowsMtp
'Decalres
Dim pCelt As Integer 'To hold the count of object found
Dim objHandles as IntPtr 'To hold the object handle? or the Ptr to the object handle?
Dim resCode as MtpLib.MTP_RESPONSECODE 'Response from API
'In my sub I use :
MTP.GetObjectHandles(65537, 0, 0, pcelt, objHandles, resCode)</code>
When I run the code I get this error :
"AccessViolationException was unhandled" - "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
I figured this was because the IntPtr variable needed to be marshaled. Problem is HOW? I don't know alot about marshaling. Can some please try and describe some working code for me? I have completed the entire program by designing around static object handles. It would really be nice to get all the files at runtime you know?
Also,
I know the storage id is correct (because I used it successfully in other API calls in the app)
AND
I know the procedure is returning the correct amount of files, because pCelt is equall to 312 after the procedure fails (and there are exactly 312 files on my device) problem is, I think the objHand is an array of file handles and I need to convert them. When I tried my hand at marshaling them, I got random numbers every time (or what seemed like random numbers.)
I have been working on this same problem nowfor two weeks I feel like I could just cry. This API seems so straight forward. Do I need to create a structure and then read / write it ? if so how.
Any help would be greatly appreciated.
|
|
|
|
|
Where did this "MtpLib" come from? Whoever wrote it is going to be your best source of information.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
The MTPLib.dll is from Microsoft's Media Tranport Protocol Kit SDK.
|
|
|
|
|
VB.Net - I am trying to create a list of currently running threads and iterate through them to abort a thread with a certain name. Like so:
'list() = list of currently running threads
'''for each thread in list
''''''if thread.name = whatever
'''''''''thread.abort
''''''endif
'''next
thanks in advance for any assistance.
John
|
|
|
|
|
That will work, so long as you add your thread objects to the array when you create them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks alot, it is up and running.
John
|
|
|
|
|
Doubtful, I'd say you should go and look in a 2nd hand bookstore for old VB6 books. MS doesn't support VB6 anymore ( for quite a while ), so no help there. www.vbcity.com is an option.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi I am tring to read a xml in vs2005
my code keeps raising the following exception: "illegal characters in path"
here is the vb.net code:
Dim ds As New DataSet
ds.ReadXml(xmlout)
ds.WriteXml("C:\Query.xml")
here is the xml doc i am reading:
<?xml version="1.0" encoding="Windows-1252"?>
<InvQuery Language='05' CssStyle='' DecFormat='1' DateFormat='01' Role='01' Version='6.0.015'>
<StockItem>
<StockCode>R00001</StockCode>
<Description>POLYCARBONATE</Description>
<LongDesc>POLYCARBONATE RAW</LongDesc>
<AlternateKey1/>
<AlternateKey2/>
<Version/>
<Release/>
<StockUom>KG</StockUom>
<AlternateUom>GM</AlternateUom>
<ConvFactAltUom> 1000.000000</ConvFactAltUom>
<ConvMulDiv>D</ConvMulDiv>
<OtherUom>KG</OtherUom>
<ConvFactOthUom> 1.000000</ConvFactOthUom>
<MulDiv>M</MulDiv>
<StockAndAltUm>N</StockAndAltUm>
<PartCategory>B</PartCategory>
<Supplier/>
<ProductClass>POLY</ProductClass>
<Buyer/>
<Planner/>
<TraceableType>N</TraceableType>
<MpsFlag>N</MpsFlag>
<SupercessionDate/>
<DrawOfficeNum/>
<Ebq> 1.000</Ebq>
<DockToStock> 0</DockToStock>
<ManufLeadTime> 0</ManufLeadTime>
<TariffCode/>
<UserField1/>
<UserField2> 0.00000</UserField2>
<UserField3/>
<UserField4/>
<UserField5/>
<LeadTime> 5</LeadTime>
<WarehouseToUse>B2</WarehouseToUse>
<GrossReqRule>I</GrossReqRule>
<EccUser/>
<Mass> 0.000000</Mass>
<Volume> 0.000000</Volume>
<PriceCategory>A</PriceCategory>
<PriceMethod>C</PriceMethod>
<CycleCount> 0</CycleCount>
<TaxCode>B</TaxCode>
<OtherTaxCode/>
<ListPriceCode/>
<SerialMethod>N</SerialMethod>
<KitType>N</KitType>
<BulkIssueFlag>N</BulkIssueFlag>
<AbcClass/>
<StockMovementReq>Y</StockMovementReq>
<ClearingFlag>N</ClearingFlag>
<AbcAnalysisReq>Y</AbcAnalysisReq>
<AbcCostingReq/>
<CostUom>KG</CostUom>
<StockOnHold/>
<StockOnHoldReason/>
</StockItem>
<WarehouseItem>
<Warehouse>B2</Warehouse>
<Description>BRAESIDE RAW MATERIALS</Description>
<QtyOnHand> 14320.580</QtyOnHand>
<AvailableQty> 14320.580</AvailableQty>
<QtyOnOrder> 333500.000</QtyOnOrder>
<QtyInInspection> 0.000</QtyInInspection>
<MinimumQty> 0.000</MinimumQty>
<MaximumQty> 0.000</MaximumQty>
<QtyOnBackOrder> 0.000</QtyOnBackOrder>
<QtyAllocated> 0.000</QtyAllocated>
<MtdQtyReceived> 15000.000</MtdQtyReceived>
<MtdQtyAdjusted> -4418.896</MtdQtyAdjusted>
<MtdQtyIssued> 19229.420</MtdQtyIssued>
<YtdQtySold> 0.000</YtdQtySold>
<PrevYearQtySold> 209807.530</PrevYearQtySold>
<QtyInTransit> 0.000</QtyInTransit>
<QtyAllocatedWip> 83114.600</QtyAllocatedWip>
<MtdQtySold Height='000' Top=' 25535'> 0.000</MtdQtySold>
<MtdQtyTrf> 0.000</MtdQtyTrf>
<UserField1/>
<UserField2/>
<UserField3/>
<DefaultBin/>
<UnitCost> 4.96228</UnitCost>
<SalesQtyByMonth>
<SalesQty1 Height='061'> 15575.800</SalesQty1>
<SalesQty2 Height='062'> 15755.304</SalesQty2>
<SalesQty3 Height='065'> 16712.316</SalesQty3>
<SalesQty4 Height='063'> 16025.252</SalesQty4>
<SalesQty5 Height='061'> 15491.400</SalesQty5>
<SalesQty6 Height='072'> 18400.806</SalesQty6>
<SalesQty7 Height='067'> 17022.060</SalesQty7>
<SalesQty8 Height='044'> 11324.508</SalesQty8>
<SalesQty9 Height='052'> 13304.464</SalesQty9>
<SalesQty10 Height='100'> 25535.280</SalesQty10>
<SalesQty11 Height='095'> 24366.672</SalesQty11>
<SalesQty12 Height='091'> 23143.720</SalesQty12>
</SalesQtyByMonth>
</WarehouseItem>
<WarehouseItem>
<Warehouse>N2</Warehouse>
<Description>NORTHMEAD RAW MATERIALS</Description>
<QtyOnHand> 36998.000</QtyOnHand>
<AvailableQty> 36998.000</AvailableQty>
<QtyOnOrder> 148500.000</QtyOnOrder>
<QtyInInspection> 0.000</QtyInInspection>
<MinimumQty> 0.000</MinimumQty>
<MaximumQty> 0.000</MaximumQty>
<QtyOnBackOrder> 0.000</QtyOnBackOrder>
<QtyAllocated> 0.000</QtyAllocated>
<MtdQtyReceived> 35500.000</MtdQtyReceived>
<MtdQtyAdjusted> 825.408</MtdQtyAdjusted>
<MtdQtyIssued> 52752.000</MtdQtyIssued>
<YtdQtySold> 0.000</YtdQtySold>
<PrevYearQtySold> 406309.904</PrevYearQtySold>
<QtyInTransit> 0.000</QtyInTransit>
<QtyAllocatedWip> -46109.144</QtyAllocatedWip>
<MtdQtySold Height='000' Top=' 55367'> 0.000</MtdQtySold>
<MtdQtyTrf> 0.000</MtdQtyTrf>
<UserField1/>
<UserField2/>
<UserField3/>
<DefaultBin/>
<UnitCost> 5.01040</UnitCost>
<SalesQtyByMonth>
<SalesQty1 Height='074'> 41175.410</SalesQty1>
<SalesQty2 Height='100'> 55367.712</SalesQty2>
<SalesQty3 Height='055'> 30331.044</SalesQty3>
<SalesQty4 Height='058'> 32120.580</SalesQty4>
<SalesQty5 Height='044'> 24530.728</SalesQty5>
<SalesQty6 Height='067'> 37250.100</SalesQty6>
<SalesQty7 Height='063'> 34816.440</SalesQty7>
<SalesQty8 Height='063'> 35081.756</SalesQty8>
<SalesQty9 Height='058'> 32207.516</SalesQty9>
<SalesQty10 Height='073'> 40260.420</SalesQty10>
<SalesQty11 Height='065'> 36142.216</SalesQty11>
<SalesQty12 Height='064'> 35711.832</SalesQty12>
</SalesQtyByMonth>
</WarehouseItem>
</InvQuery>
Any help would be appreciated
Cheers
|
|
|
|
|
thedom2 wrote: ds.WriteXml("C:\Query.xml")
How does VB handle \, do you need to do \\, as in "c:\\query.xml" ? You do in C#.
thedom2 wrote: xmlout
I guess you need to step through the code, see what's in this variable, and see if this or the next line is blowing up.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: How does VB handle \, do you need to do \\, as in "c:\\query.xml" ? You do in C#.
Not true for VB. Single "\" work just fine. Doubles are required in C\C++\C# unless the string escaped by some literal character, @"" or L"" or whatever...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|