|
Is this a Windows application or a web application?
---
b { font-weight: normal; }
|
|
|
|
|
When you return focus to the main form the FormLoad event does not fire. What you probably want to do is put all (or most) of the code that is currently in your FormLoad event handler and move it into a public subroutine. When you close the second form, first have it call this new public subroutine to reload the main form's data before returning to the main screen.
Hope this helps.
|
|
|
|
|
i've looked and tried fixin this problem until i'm ready to pull my hair out. hopefully someone has the answer.
i want a combo box to display names from a table. the table has 2 fields (CoordinatorID and Coordinator). the id field is sequential.
when i run the program, the combobox works but assigns the place in the combobox as index instead of the CoordinatorID as the index (see code below). if i don't sort the list (removing "ORDER BY coordinator") it works fine, but i have to have it sorted for the end user.
what am i doing wrong? any help greatly appreciated,
thanks, chris
Public Sub FillCBO()
rs1.Open "SELECT * FROM tblCoordinator ORDER BY coordinator", Conn, adOpenStatic
If rs1.EOF = False Then
rs1.MoveFirst
Do
cboCoordinator.AddItem rs1.Fields("Coordinator")
cboCoordinator.ItemData(cboCoordinator.NewIndex) = rs1!CoordinatorID
rs1.MoveNext
Loop Until rs1.EOF = True
End If
rs1.Close
Set rs1 = Nothing
End Sub
|
|
|
|
|
AFAIK, the combobox will show items in the order passed in, unless you have the sorted property set to true.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
HI all
i wanna to create an application that must use functions in another computers.my application is ntier.and the dataaccess layer is in another computer that implemets an interface with name IDataAccess ,in the client application (UI) i must use DataAccess 's functions that referece them with new so i have to use Client Activator .and i dont want to use proxy.
Is there anybody that can help me
regards
Maryam82
|
|
|
|
|
I have a datatable that I have retrieved from a database (w00t!)
now I am trying to add a column to this datatable, but the add command only allows me to add a datacolumn to the end of the datatable collection
I want to add my new datacolumn to the start of the datatable (or potentially at any index ) and I haven't been able to figure out how to do this.
Any hints?
Thanks in Advance,
Jason
|
|
|
|
|
You can't add a column at any index you want. Anything you add will always be appended to the end. Besides, a DataTable object has no visible component, so it doesn't matter where the column is appended... Why do you want to do this?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm setting it as my datagrid datasource.
I'm reading data from several sources in my database. Based on the type of data I'm reading (whether it is Contact data or Business data etc) I wanted to add an icon column to my datagrid. This works fine, except the icon is the last column in my datagrid, I want it to be the first.
I assumed that I would do this at the datatable level, not at the datagrid level.
Jason
|
|
|
|
|
The view of the data is maintained seperate from the data itself. The order of the columns in the datatable has nothing to do with the order of the columns in the datagrid. In order to do this, you'll have to create all your columns, in the order you want, and add them to the grid.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
so how is this done? I already have my datatable (tblMergedContactsAndCompanies). I want to add a new column at index 0 and then read through all the rows in my datatable and assign an icon depending on Type (Contact or Company) and then display this in a datagrid.
I can add the icon column to my datatable, but when I display it in my datagrid, it is at index(datatable.columns.count).
Dave Kreskowiak wrote: In order to do this, you'll have to create all your columns, in the order you want, and add them to the grid.
Are you saying that I have to create a new datatable, read the columns from my original datatable in, and then read the data in?
Jason
|
|
|
|
|
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
|
|
|
|