|
Hi All, (using Vb.net & VS 2008)
I have the following problem which has stumped me for the last few days :
I have a form with a Datagridview showing products ordered by customers over a 14 day period.
Also on the form I have an external combo box. The combo box is populated with customer names.
My plan is to have the user select a customer name via the external combo box then have the datagridview filtered with orders for the selected customer for the 14 days
So far, this is what is happening :
The Datgridview displays orders for All customers correctly over 14 days
The combo box displays a drop down list of All customers correctly
So far this is not happening :
Selecting a customer from the combo box doesn't change the datagridview to show only the selected customer orders. Orders from all customers show regardless of which customer is in the combo box selection.
Here is the code I am using :
-----------------------------------------------------------------------------------------------
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim connection As SqlCeConnection = New SqlCeConnection()
connection.ConnectionString = "Data Source=\SD Card\DB.sdf;"
connection.Open()
'Populate the orders datatable from the Order table
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT my select statement goes here", connection)
Dim mybindingsource As New DataTable
da.Fill(mybindingsource)
DataGridView1.DataSource = mybindingsource
'Populate the Combo Box with Cust ID & Names from the Account table
Dim cboda As SqlCeDataAdapter = New SqlCeDataAdapter("SELECT ID, AccountName FROM Account", connection)
Dim cbods As DataSet = New DataSet
cboda.Fill(cbods, "Account")
Dim dt As New DataTable
dt.Columns.Add("ID", GetType(System.String))
dt.Columns.Add("AccountName", GetType(System.String))
Dim drcbods As DataRow
Dim drNewRow As DataRow
For Each drcbods In cbods.Tables("Account").Rows()
drNewRow = dt.NewRow()
drNewRow("ID") = drcbods("ID")
drNewRow("AccountName") = drcbods("AccountName")
dt.Rows.Add(drNewRow)
Next
cboCustomers.DropDownStyle = ComboBoxStyle.DropDownList
With cboCustomers
.DataSource = New DataView(dt)
.DisplayMember = "AccountName"
.ValueMember = "ID"
End With
-------------------------------------------------------------------------------------
I have the following code under the Combo box selectedValueChanged event
Private Sub cboCustomers_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCustomers.SelectedValueChanged
Me.myBindingSource.Filter = "Account_ID= '" & cboCustomers.SelectedValue.ToString & "'"
-------------------------------------------------------------------------------------
Fields in the Order datatable are : Account_ID, AccountName, Product_ID, ProductName, OdrQty1,......OrdQty14
Fields in the Account datatable are : ID, AccountName
In the underlying DB the Account and Order tables are linked via Account.ID = Order.Account_ID
I greatly apperciate any advice or assistance.
Many Thanks
Ku Mungi
|
|
|
|
|
Have you tried to used DataView[^] class as your datasource. Filtering is quite easy with that.
|
|
|
|
|
Thanks for the reply, I will check out the DataView class as suggested.
|
|
|
|
|
Mika Wendelius wrote: Have you tried to used DataView[^] class as your datasource. Filtering is quite easy with that.
I now have this working perfectly with a dataview and linq statement.
Thanks for pointing me in the right direction. Cheers
K
|
|
|
|
|
You're welcome
|
|
|
|
|
Hello everyone there,
I have following two problem with vb.net2005
1. I am trying to create a setup file for my application. I created the setup project(by adding setup and deployment project to my existing workspace),and without making any change(or chacking any option) I build the setup project. But when I try to install the created SETUP exe it pops up an error "the folder path '.' contains an illegal character"
Could anyone please help me out with the problem.
2. Also please give me the basic option to select (or to take care), while deploying a project. I am using vb.net2005 with crystal report.
Thanks in advance
I am a learner Always
|
|
|
|
|
|
Do not cross-post. It's considered rude.
|
|
|
|
|
I'm working on a utility that will allow the user to query some data from a database and output it.
I would like to support allowing the user to provide a format for the numbers, particularly if hexadecimal representation is desired.
Ideally I could simply do ((System.IFormattable) datarow [ columnname ]).ToString ( format , null ) , but when hexadecimal is requested the user may (should) want to tack on a leading "0x" and I've been unable to form a format that will do that.
What should work is "'0x'X4" , the '0x' should be copied to the output and then the value should be formatted with X4.
From the documentation:
"
'ABC' "ABC"
Literal string
Characters enclosed in single or double quotes are copied to the result string, and do not affect formatting.
"
Bull-pucky; they do affect formatting, they screw it up!
The closest I've gotten is string.Format ( format , datarow [ columnname ] ) with a format of "0x{0:X4}", but the user shouldn't need to specify the braces and such.
I'm considering using a Regular Expression and pre-processing the format to remove literal text before passing it to ToString, and concatenating the thing back together afterward.
I'm hoping someone here has a better solution.
|
|
|
|
|
The format characters you use should be enclosed with {}. I think there's nothing you can do about it.
I think the main question is what kind of options do you want to offer to the user? For example if you want to use syntax like:
"Hex, 4"
That would be converted using something like the following (with proper checks for the syntax):
If (format.StartsWith("hex", StringComparison.InvariantCultureIgnoreCase)) {
formatString = string.Format("0x{{0:X{0}}}",
int.Parse(format.Substring(format.IndexOf(',') + 1)))
}
|
|
|
|
|
Mika Wendelius wrote: enclosed with {}.
That's only with string.Format and its ilk. Which, as I said, works, but isn't ideal; the user would need to know too much about the internal workings of the program.
I could also just not support hex; after all, the database won't display the values that way.
I could also not allow a width specifier.
I could have hex and width specified separately.
On the other hand, this is just one simple utility; in the future I may have a project that really requires this.
I'd much prefer to use ToString and allow the user to specify "any valid Custom Numeric Format String[^]"
That should offer the greatest flexibility with the least intervention on my part. And it should work, according to the documentation.
I'll investigate my RegularExpression idea some time today. Thanks for your response.
|
|
|
|
|
PIEBALDconsult wrote: And it should work, according to the documentation
I'm pretty sure it works. Although I haven't used it so that the user gives the format, I read the format typically from database and it works fine.
PIEBALDconsult wrote: I'll investigate my RegularExpression idea some time today
Possibly the best way to go.
PIEBALDconsult wrote: Thanks for your response
No problem.
|
|
|
|
|
Mika Wendelius wrote: I read the format typically from database
For this utility I'll get it via XML file, but the user who creates the file should be able to specify what he wants without knowing much about the internal plumbing.
An added bonus to how I envision working around this problem responding pro-actively to this opportunity is that I can allow multiple sub-formats in the format.
With string.Format I can use "{0:X4}={0}" to format the same value into the output twice, but ToString doesn't seem to support that on its own: 20.ToString ( "X4'='0" ) results in X4=20 .
But if I pre-process the format, I can add support that I feel ToString should have; split the format into { "X4" , "'='" , "0" } , then iterate and if the sub-format is literal text, output it (Append to a StringBuilder), otherwise pass the sub-format to ToString and output the result.
The resultant process should then better match how I understand ToString should work with custom numeric formats.
|
|
|
|
|
|
Well, that, was easy. I just don't think it's enough to form its own article.
20.ApplyFormat ( "'0x'X\"=\"0d" ) yields "0x14=20d"
|
|
|
|
|
Seems easy, but a stupid question: What's ApplyFormat? It doesn't seem to be any .Net method for int.
|
|
|
|
|
Ah, see? Obfuscation. That's the Extension Method I just wrote.
|
|
|
|
|
That's what I thought
Well, if the implementation is more than one line perhaps you should still consider the article
|
|
|
|
|
Yeah, I think I will.
But I've also been directed to Customizing Format Strings[^], so I'll look through that to see if it may be a better or complementary technique.
|
|
|
|
|
I submitted the article, we'll see what happens.
|
|
|
|
|
Is this the right spot to ask questions about Visual Studio 2008 extensibility?
I am writing a Visual Studio 2008 Integration Package, using the SDK, and I would like to attach behavior code to the designer drag events (DragEnter, DragOver and DragDrop). I have a custom tool window with a list of available commands to our electronic measurement device. I want the ability to drag a command from that list onto the surface of a winform designer. Dropping the command item should automatically create the default control type and write the code that hooks it to the equipment command. Alternatively, I'd like it if the user could drag a command onto an existing control and have the connection code written.
I think I see how to automate the creation of controls and code in a Form designer, but I can't figure out how to hook that code to the designer drop event.
Thanks,
Aaron
|
|
|
|
|
As far as extending the designer capability for controls, one of my articles might be able to help you: Targeting Design-Time Events of UserControls[^].
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hello,
In VB.NET or C# (and generaly in DOT NET)
How to get the Owner / Creator of a document / file ?
I know hot to get modification date, creation date
but not the OWNER of the file.
How to access to the Security Attributes in order to get the OWNER ?
Best regards
|
|
|
|
|
Off the top of my head, you can use WMI and the System.Management namespace to get the Win32_LogicalFileSecuritySetting[^] object for that file. Call it's GetSecurityDescriptor method and that will return a Win32_SecurityDescriptor[^] object, which will have the information you're looking for in its Owner property.
|
|
|
|
|
Use the FileInfo.GetAccessControl() method to retrieve a FileSecurity object. Then call FileSecurity.GetOwner() to get the owner of the file.
|
|
|
|