|
dvsriram wrote: Now i can save and retrieve the datagridview from/to xml
So that's what you were trying to do??
That's easy to do if your data is in a DataTable and you bound the DGV to it. All you would have to do is call the DataTable's WriteXml method. Done.
|
|
|
|
|
I am facing problems to update combo box value that is binding to a datasource ... i m using VB.NET 2005 and SQL SERVER 2000 at back.
I simply created a Data Source. And added 'PurchaseOrders' Table in it. Set it to draw 'DETAILS' components. and dragged it on to the form and it draws all the controls on the form. along with a navigator and binding source, dataset added to the form.
Now i have a field ... SUPPLIER ID and its component was set to a COMBOBOX.
I seprately loaded this combobox with a datasource as:
SupplierIDCombobox.Datasource = DsSupplier.Tables(0)
SupplierIDCombobox.DisplayMember = "SupplierName"
SupplierIDCombobox.ValueMember = SupplierID
now when i run the program, the first SupplierID is picked by the combobox correctly.
When i navigate to second purchase Order. the supplierID does not change.
How to fix this problem??? anyone?
:- Rashid Ali -:
|
|
|
|
|
OK. There's a few things you have to do.
First, you need a second BindingSource and set it's DataSource and DataMember properties to the table that's going to supply the ID's and Text for the ComboBox to show. It helps greatly if the DataSet you're using has both the table that you're already showing and the table that's supplying the data for the ComboBox. There's normally a one-to-many relationship between these two tables.
The DataSource property of the ComboBox needs to be set to the BindingSource you just created. Also set it's DisplayMember to the field that's supplying the Text the user gets to see in the Combo and set the ValueMember property to the field that's supplying the ID's for those text items.
Then, create a new Binding object and add it to the DataBindings property of the ComboBox. This binding needs to bind the SelectedValue property of the ComboBox to the original BindingSource you already have on the form and the name of the field in that bindingsource that's going to hold the value selected in the ComboBox.
|
|
|
|
|
.
.
.
you need a second BindingSource and set it's DataSource and DataMember properties to the table that's going to supply the ID's and Text for the ComboBox to show.
I wrote code manually to get get ID and Name fields from database. here is the code.
Private Sub LoadSuppliers()<br />
<br />
m_CommandSupplier = New SqlCommand<br />
m_CommandSupplier.CommandText = "Select SupplierId, SupplierName from Suppliers"<br />
<br />
Try<br />
m_DaSupplier = New SqlDataAdapter<br />
m_DaSupplier.SelectCommand = m_CommandSupplier<br />
<br />
m_DaSupplier.SelectCommand.Connection = m_ConnectionSupplier<br />
<br />
m_DsSupplier = New DataSet()<br />
m_DaSupplier.Fill(m_DsSupplier)<br />
<br />
Catch ex As Exception<br />
<br />
MsgBox(ex.ToString, MsgBoxStyle.Critical, " Get Suppliers")<br />
<br />
End Try<br />
<br />
m_DsSupplier.Tables(0).TableName = "Suppliers"<br />
<br />
1 - it's DisplayMember to the field that's supplying the Text the user gets to see in the Combo and set the ValueMember property to the field that's supplying the ID's for those text items.<br />
<br />
2 - create a new Binding object and add it to the DataBindings property of the ComboBox<br />
<br />
Both these task are accomplished in the following code, SupplierNAme is set as Display MEmber , while the SupplierID is set a value member.<br />
<br />
With SupplierIDComboBox<br />
.DataSource = mDsSupplier.Tables("Suppliers")<br />
.DisplayMember = "SupplierName"<br />
.ValueMember = "SupplierId"<br />
.DataBindings.Clear()<br />
.DataBindings.Add("SelectedValue", PurchaseOrderDetailsDataSet.PurchaseOrders, "SupplierId")<br />
<br />
End With<br />
<br />
<br />
End Sub
the table that's supplying the data for the ComboBox. There's normally a one-to-many relationship between these two tables.
The Table that supply the value for both tables is actually a Binding Source with a binding navigator to move back and forth. All these were automatically drawn when i dragged the 'PurchaseOrder' Table from Datasources window.
Note: 'PurchaseOrder' table was set to draw control in 'DETAILS mode' while "PurchaseOrderDetails" table was set to 'DAtagridview mode'.
Now when i run the program, the value for PurchaseOrder and PurchaseOrderDetails tables in both Details and datagrid goes fine.
But when i click 'MOVE NEXT RECORD' button from BINDING NAVIGATOR. All the values in Textboxes and DATAGRIDVIEW changes accurately. But the values in comboboxes like SUPPLIER ID does not change. and it stick to the value that was loaded with FIRST RECORD. What should i do?
:- Rashid Ali -:
|
|
|
|
|
Hello all,
I search an sample on how to create a vpn connection in vb.net
i have found some codes in c# or VisualC ... but i not able to translate it correctly.
Someone can help me ?
Thanks a lot.
|
|
|
|
|
Post the C# code or a link to it and the code you've written. Noone is just going to write the code to do this for you. You have to show an effort on your part before anyone is going to help you with this.
|
|
|
|
|
My main report has a sub report that has a table in it with an associated dataset. When I run the report, the main data displays, but the area that is supposed to show the sub report shows "sub report could not be shown"
Please tell me step by step create sub report with report viewer in vb.net
please help me, its urgent
Thanks
|
|
|
|
|
It's probably saying this because you either don't have any records for the sub report, the data tables you're using don't have any relationship between them, or the subreport isn't configured properly.
Describing all of this would take up a few articles. There's no way anyone is going to do this in a forum post.
...and noone cares how "urgent" it is when you're not paying for support.
|
|
|
|
|
how can i hide the Start Button in Vista using VB.NET2005??
Please give me a code!!!!
from japan(sorry for bad English)
|
|
|
|
|
|
thank you your reply.
im upgrading the application from XP to Vista.
my program fails to hide and disable startbutton in Vista..
the link is really helpful for me!!!!
i could make startbutton disable with using API EnableWindow.
i've tried using showwindow,SW_HIDE and its only made startbutton smaller.
my client said it is okay only disable startbutton not hide.
i really appreciated your answer!!!!
|
|
|
|
|
hello guys!
I know this question might sound a litle stupid but this my first application and things are still confused for me.I'm developing a data centric application in VB.NET with Visual Studio 2005 that is supposed to connect to sql server installed on the machine or in the network.
For exemple in my application project i use the data adapter to connect to the database X with my settings (i mean my user name and password of the sql server on my machine or integrated security) in the connection string on every windowsforms.
Then i wanted a way to deploy my application that will create my database during the installation.I liked one of the msdn ways that use the installer class to read an sql file.But i was more interrested by the method used by
Mukund PUJARI in his article "create a database during installation version 2".My anxiety is this:if the end user has the freedom to choose the database Y and his location, then my application will definitively not be connected to the database end since my connectionstring is different connection to a database X.
In my point of there should be a method that can put in the connectionstring the data provided by the end user.I don't have any idea.Even though i knew and then using data adapters and datasets stuffs how can i make them use it?Supposing i kew it too,it would be then after deployement that i can test that my application is using the database name that i provided during installation.
All this are confusing me and if somebody can just help it would make a programmer have a litle more knowledge
thanks
eager to learn
|
|
|
|
|
You can replace the name of the server, the database name, user name and password at runtime and update the connectionstring in config file.
For example:
Driver={SQL Native Client};Server={0};Database={1};Uid={2};Pwd={3};
You can replace the string like that ~
String.Format(Driver={SQL Native Client};Server={0};Database={1};Uid={2};Pwd={3}, txtServerName.Text, txtDatabaseName.Text, txtUserName.Text, txtPassword.Text) <br />
then, you can update your config file if you want to.
|
|
|
|
|
hi michael thanks for giving so fast answera though i'm not sur i understood.Right now i don't know how to do such a thing, should it be in the installer class?In my architecture i have about 8 forms and 3 crystalreports and each of them has at least one data adapter.then i add an installer class that use a masterconnectionstring and then change the database master to the one provided by the end user in a user interface.The values entered is past to a variable in the overrided install method(if i'm not wrong).So it 'll read my sql text file to create all the object of this database.How should i implement what you just suggested?
Thanks a lot.i went to michael.net not bad
eager to learn
|
|
|
|
|
I NEED SOME HELP DETERMINING WHERE TO START IF YOU WANT TO BE PROFICIENY IN VB OR VB.NET
|
|
|
|
|
1 - DON'T SHOUT
2 - BUY A BOOK
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
how can i access status bar on MDI form from child or methods in Module file?
|
|
|
|
|
You don't. The module shouldn't have any need to get at the controls of a form. The module should be concerned with just doing it's job, not updating controls. The only thing that should be updating the controls on a form is the form itself. (There's a multitude of reasons for this...)
There really is no use for modules anymore, other than backward compatibility with VB6 users. But, in either case, your code should be exposing an event or a delegate callback that the form subscribes to in order to receive update messages.
|
|
|
|
|
sorry foy my english again.
I want clic on my WinForm and move it (rigth, left, up, down)
how can i do it?
i am from mexico....thanks CodeProject
|
|
|
|
|
You need to write the code to do this, handle a mouse down, mouse move and mouse up on your form. While the mouse is down, if the mouse moves, move the form.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
This Works like a dream for me.
Dim pt as point
dim hdMousDown as Boolean
Private Sub SetPoint()
If hdMousedown = True Then hdMousedown = False Else hdMousedown = True
pt = Me.PointToClient(Control.MousePosition)
End Sub
Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Form1.MouseDown
SetPoint()
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Form1.MouseUp
SetPoint()
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Form1.MouseMove
If hdMousedown = True Then
Me.Location = New Point(Control.MousePosition.X - pt.X, Control.MousePosition.Y - pt.Y)
End If
End Sub
|
|
|
|
|
A couple of days ago I posted the questionon how to do this:
Datagridname.Columns.Add(New DataColumn("Name", Gettype(String)))
for a gridview and I got this answer: "It said it suppose to be a DataControlField. DataControlField is the abstract class of TemplateField, BoundField, hyperlinkfield and etc.. "
BoundField bf = new BoundField();
bf.DataField = "DateOfBirth";
GridView1.Columns.Add (bf);
Thank you so very much - you helped tremendously. Now I'm wondering if you or anyone else can help me to create an Itemtemplate field in the same manner - I need it to be a dropdownlist but don't see where the dropdown is a choice for the Itemtemplate. Any help on this would be greatly appreciated. And - the help I received is VERY appreciated! Thanks!
Coleen
"Even the smallest foot leaves an impression"
|
|
|
|
|
You can use TemplateField instead of BoundField.
|
|
|
|
|
Thanks Michael - I tried that; the problem is that there is not a member of the TemplateField that allows me to "tell" that field that it needs to be a dropdownlist in the VB codebehind. When I do this:
Dim tfModeTy as new TemplateField
tfModeTy. there is no selection of dropdown list - so I tried tfModeTy.EditItemTemplate and the only available method is InstantiateIn - which I don't understand how to use. Is there any documentation on how to make the EditItemTemplate into a dropdownlist? I've gotten a very good link on this - but unfortunately I don't quite understand how to implement it. It really makes no sense that in the ASP.Net code I could easily write:
<asp:TemplateField HeaderText="Cities">
<ItemTemplate>
<asp:DropDownList ID="ddlCities"AutoPostBack="true" runat="server"
OnSelectedIndexChanged="ddlCities_SelectedIndexChanged"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
And yet in the VB Code Behind there is no option on the ItemTemplate of DropDownList! Why not? And if there is, can you please give me an example of what it is - 'cause I sure am not getting those choices in my VB.Net codebehind!
Thanks!
Coleen
"Even the smallest foot leaves an impression"
|
|
|
|