|
Set the combo box's "DropDownStyle" to "DropDownList"
|
|
|
|
|
ya it works but it don'nt show the display text like "select country" how i can do it
|
|
|
|
|
Set your Text Property to "Select Country"
|
|
|
|
|
Hi,
Directly you wont be able to assign that. What you need to do is when you are binding it at that itself you add that to your datasource.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hello,
I'm working with the datagridview and I want format the columns with values from a database
code :
For Each DC In DGV.Columns
Dim cell As DataGridViewCell = New DataGridViewTextBoxCell()
'Dim cell As DataGridViewCell = New DataGridViewButtonCell
Me.Text = DataList.TableColumns.Rows.Count
DC.Tag = 0
DC.Tag = DataList.TableColumns.Rows(DC.Index).Item("PrgFormule")
If DC.Tag = 0 Then
cell.Style.BackColor = Color.LightGray
DC.ReadOnly = True
Else
cell.Style.BackColor = Color.White
DC.ReadOnly = False
End If
cell.Style.ForeColor = Color.Blue
DC.DisplayIndex = DataList.TableColumns.Rows(DC.Index).Item("Orde") - 1
DC.AutoSizeMode = DataGridViewAutoSizeColumnMode.None
DC.Width = DataList.TableColumns.Rows(DC.Index).Item("Width")
DC.HeaderText = DataList.TableColumns.Rows(DC.Index).Item("Caption")
Select Case DataList.TableColumns.Rows(DC.Index).Item("Align")
Case 1
cell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
Case 2
cell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
Case Else
cell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft
End Select
cell.Style.Format = "#0.00"
DC.CellTemplate = cell
Next
DGV.AllowUserToResizeColumns = True
DGV.AllowUserToResizeRows = False
The first time the code works just fine, but after selecting an other list the formatting is not working, then I select the same second list and then it works fine again.....
any suggestions ?
Thanks...
|
|
|
|
|
Interesting. Kschuler(sp?) is having an issue with a mousepointer not working when a user clicks on a column to sort. I wonder if these to issues are related. If there's an inherit problem with the grid loosing formatting after a user clicks the column header, that could cause the cursor to not update as well :/
I don't have any suggestion at the moment, but I'll do some testing and try to recreate the problem. What version of VS are you using?
|
|
|
|
|
Hello,
I'm using VB 2005 express edition. The database is Mysql
The first 3 columns in both list are the same, and there I have the same formatting as in the previous list
so it is like the grid keeps the same celltemplate from the previous list, but the caption is changed
|
|
|
|
|
I want to sort the database in ascending order! how can i make this happen with a button click event? can someone help me please??
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Typically sorting that is done with a mouse click isn't done by the server. Usually it's done by the container that is displaying the information. Typically a container will have a sort function built in to it. If it doesn't you can add a function to sort the Dataset taht's attached to it, then refresh the container.
If you're wanting to pull the information from the database presorted, then add " ORDER BY " and then the field name you want it sorted on. You can Default is Asc, however you can add "DESC" to the end to get reverse order.
|
|
|
|
|
First of all fill the dataset from the database
Dim myView as DataView
myView = ds.Tables("Customers").DefaultView
Here I am creating a DataView called myView, and assigning the results of the query (ds.Tables("Categories").DefaultView) to it.
You would create sort property by an 'Order By' clause in a SQL query. In an 'Order By' clause, what you're doing is ordering the ouput display by a field or fields in the database, in either Ascending or Descending order. If you add 'DESC', for descending, the default is 'ASC', so you really don't need to address this if your needs are fulfilled with the display results in ascending order.
All you really need to do to sort your dataview is to assign the field or fields you need sorted to the 'Sort' property, like this:
myView.Sort = "Region"
So, to sort by multiple fields, in a Descending order, you'd do it just like you would in an 'Order By' clause:
myView.Sort = "Region, City DESC"
Kumar Prabhakar
|
|
|
|
|
Hi,
I'm working with a sqlserver database & i extract records from it to my application built in vb.net
i have finishid my small app. but now i need to complete my deployement
i have deployed it , not completly because i didn't understand somethings like why adding a key in register & some stuffs
but i had a .msi file & everything is going ok
now i want to know how to take the database with me i mean with the application or with the .msi file
i will give an example to make is more clear
supposing i have my database in "C:\MyDataBase"
now each time i want to install my application in an other PC i have to copy this Data files & past them in the same root "C:\MyDataBase" in the other PC
now i'm asking if it is a possibility to do that just in vb i don't know , sepecifying a root or something like that & then once i install ma application the data files will take there position & i won't have problems in the programme
an other thing , actualy i didn't like the standar forms given with deployement project i want to built my own ones can you tell me how ??
thank you very very much , i hope you undertood that stupide english
try to be good if you can't be the best
|
|
|
|
|
I don't know how to create your own forms for deployment, but I am currently working on a program with a similar database situation. In a setup project bring up the File System Editor. On the side you will see a list of folders including Application Folder, User's Desktop, and User's Programs Menu. What ever you put in these folders will appear in their respective places. This is how you can specify during setup that you want to place a shortcut on the user's desktop for your program, etc. I use the Application Folder as a location for my database and the final .exe of my application. Then, in the code of my application, when I need to setup the connection for my database I use the following code to find the folder my application resides in (which is the same as the database):
My.Computer.FileSystem.GetParentPath(Application.StartupPath) & "MyDatabaseName.mdf"
Hope this helps.
|
|
|
|
|
the easiest way to create custom installation programs is to get DevStudio from InstallShield. Visual Studio used to ahve a copy that worked with C++. I haven't seen it with VS 2005(but I haven't looked that closely either). As far as customizing the setup wizard that comes with VS, it's very limited.
|
|
|
|
|
well , thanks i got all the first paragraph but actualy what i didn't get is that line :
My.Computer........
this is how we declare a connection object :
Public Con As New SqlConnection("workstation id=ORDI_AMINE;packet size=4096;integrated security=SSPI;data source=ORDI_AMINE;persist security info=True;initial catalog= GHotel")
now can you tell me how to do that
i added the two files "MyDataBase.Mdf" & "MyDataBase.Ldf" to application folder in an other folder that i had created in & i named it Data
so now i have ApplicationFolder\Data\"MyDataBase.Mdf" & "MyDataBase.Ldf"
tell me please how to make that work
GHotel : is My Data Base
ORDI_AMINE : is the name of ma PC
aahhh !! i forgot , i tried to write localhost instead of ORDI_AMINE & it doesn't work
please try your best with thanks
try to be good if you can't be the best
|
|
|
|
|
Sorry....I should have specified that the My.Computer....code only works in Visual Studio 2005. To do this in Visual Studio 2003 you can use this:
System.IO.Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetName().CodeBase)
But you will need to include Imports System.Reflection
I'm not familiar with your method of creating a connection. Whenever I make a connection object I give it the full file path to the database file. Like in this connection string:
<br />
strDataBaseLocation = "C:\Program Files\MyApplicationData\MyDataBase.mdf"<br />
strConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename='" & strDataBaseLocation & "';Integrated Security=True;Connect Timeout=30;User Instance=True"
But since users may want to install to a different location, I just make sure that my database is always in the same relative location to my .exe.
Does this help you any? I just don't understand how your program knows where your database file is without the full path in the connection object.
|
|
|
|
|
Oh yeah sure i learned a new way to declare connection thank you
but actualy the f***en problems stills the same it doesn't want to work
i think it want to jock i will break the f***en mind of this PC
actualy i don(t understand too how it can know the way of the database without giving it the location
but i think it knows the server & the server show the way to this stupide programme
well i will thank you a lot if you can speak all the code you wrote abt that new classes & assemlies & stuffs plus i want to tell you that i added the two files Mdf & Ldf
to the application file in the deployement project
i hope this will work later when we know how to tell him to attach a database
i hope you want to help me & thank you for all what you did for me
try to be good if you can't be the best
|
|
|
|
|
I have a DataGridView control in a Windows Application project with the first three columns being image columns. (They contain icons for navigating to other forms for editing, viewing, and deleting) There isn't a property to set on these columns for changing the cursor from the default arrow into a hand, so I wrote the following code to manually make that happen:
Private Sub gvMast_CellMouseEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gvMast.CellMouseEnter
Select Case e.ColumnIndex
Case 0, 1, 2
Select Case e.RowIndex
Case -1 'Header row
Cursor = Cursors.Default
Case Else
Cursor = Cursors.Hand
End Select
Case Else
Cursor = Cursors.Default
End Select
End Sub
Private Sub gvMast_CellMouseLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gvMast.CellMouseLeave
Cursor = Cursors.Default
End Sub
The problem I'm having is that after the user sorts a column by clicking in the header row of the DataGridView, this code doesn't work anymore. The cursor remains the default arrow. Debugging is a mess because everytime you hit a breakpoint you will hit the CellMouseLeave event, but it appears to be hitting the code that sets the hand cursor.
Anyone have any ideas?
|
|
|
|
|
Your code looks good. Is it possible that your sort is causing you to loose focus on the gridview? The way I get around break points is to fire a Messagebox.show method with the information I'm looking for.
Add: Messagebox.show(e.columnIndex + vbCrLf + e.RowIndex) into your cellmouseenter event and that will get the values displayed before you leave it. That will at least let you know what values are being passed to it. If none are being passed, then your control isn't capturing the mouseenter and mouseleave events.
|
|
|
|
|
Using a messagebox doesn't work either, since after you click okay on the messagebox it hits the cell mouse enter method again...creating a loop. But working off this idea I added code to change the text of a label instead. Every place I changed the cursor in code I added a different message to change the label text to. It appears as though it is hitting all of the code correctly, it is just not displaying the hand cursor. (My label text gets changed to the word "HAND" appropriately)
I'm still at a loss.
|
|
|
|
|
Interesting. I'll have to play around with that a bit and see if I can reproduce it.
|
|
|
|
|
Hi all. I'm in the process of updating a dataset to my web app. Here is the scenario...
I added a location field to the 'clients' table in the database. The database is already represented in the .xsd file. I added the location field to the table in the .xsd file. I bound the field to a text box in one of the web screens (this screen has client name, id#, and location (new field)). I also had to update 2 stored procedures (clients_add, clients_modify) to include the location field name.
Now that the changes were made, I cannot update an existing client via the web interface. I can still add a new one though. I even tried to remove all the changes I made in hopes of reverting it back to the previous state - no luck. Please let me know if you have any ideas. Thanks.
- J
-- modified at 12:06 Wednesday 24th May, 2006
-- Edit: there is a 'managers' table in the dataset too. I have not touched it, and the edit piece is still functioning correctly. Not sure if this helps.
|
|
|
|
|
The first thing i would do is start ruling out different aspects of the process.
Load up SQL Profiler and watch the commands that come through fromthe website. You should see it execute the stored procedures as you modify them. It will also let you knwo what parameters are being passed. Make sure they're correct. If not, it will give you an idea of where the problem is in the page.
If everything is hitting the SQL server correctly and the stored procedure is failing, then use Query Analyzer to step through the stored procedure. Use the same variables you used in the initial test so that you can narrow down where the issue is. Also, don't forget that SQL is case-sensitive.
HTH
|
|
|
|
|
Thanks. That helped me find out the sproc is getting called. I also ran the sproc manually and it completed correctly. However once the sproc runs, the data isn't getting transferred into the database. Any other ideas? Thanks in advance.
- J
|
|
|
|
|
If you run it manually and it works, but doesn't run properly from code, then there's an issue with how the code is calling it. Make sure you have all of the connection strings correct, the SP spelled correct and all expected parameters are formatted correctly.
If you go back to the profiler, you can adjust the settings to show every time something attaches to the database and what's being passed. If you click the button on the form and nothing shows up in the log, then theres an issue with the connection string. If a connection shows up in the log, but the sp is never called, then it's probably spelled incorrectly. If the sp is called but never runs, then there's probably an issue with the parameters.
A way to test your parameters is to hardcode the parameters into your button and click it. If it runs that way, then add one variable parameter at a time until it no longer runs. Keep in mind that certain data types need certain formatting on the parameter side. A way to verify this is using named parameters (which you should already be doing to prevent SQL Injection).
Let me know if that works.
|
|
|
|
|
The profiler lists the following when the sproc is called...
exec sp_executesql N'EXEC Clients_Modify (parameters following - they are correct)
Does this mean the sproc has run or has been called?
Sorry for the extra questions, I'm fairly new at this. Thanks.
|
|
|
|