|
i am passing information from listbox to another listbox in a different form by just pass using system
this is the code i'm passing with
string[] items = new string[lstSelectedItems.Items.Count];
amoun = txtAmount.Text;
lstSelectedItems.Items.CopyTo(items, 0);
FrmOrderDetails order = new FrmOrderDetails(txtAmount.Text,items);
order.Show();
this is the code in a form that i want to accept the data am passing
string it;
private string totalprice;
public string Totalprice
{
get { return totalprice; }
set { totalprice = value; }
}
public FrmOrderDetails(string tprice, string[] items)
{
InitializeComponent();
it = items.ToString();
tprice = Totalprice;
private void FrmOrderDetails_Load(object sender, EventArgs e)
{
totalprice = txtTotalPrice.Text;
lstOrderDetails.Items.Add(it);
}
|
|
|
|
|
And your question is?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
|
The problem in your code is this
it = items.ToString();
line.
items.ToString() will give "System.String[]" (in other words a description of the Type you are using not its contents). Not what you want, I suspect.
Investigate the String.Join() method for one possible solution.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas?
Because 31 Oct = 25 Dec.
|
|
|
|
|
nowhere to be seen.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
ask a proper question and/or give precise symptoms, and please use PRE tags to show code snippets.
Maybe what you need is similar to
lb2.Items.Add(lb1.SelectedItems);
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Suppose there is an element in XML data:
<abc:xyz:name attr="value"/>
I'm trying to read it with XmlReader. The problem is that I get XmlException that says:
The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name
I have already declared "abc" namespace. I have also tried adding "abc:xyz" and "xyz" namespaces. But this doesn't help at all. I could replace some text before parsing but there may be some more elegant solution. So what should I do?
Here is my code:
XmlReaderSettings settings = new XmlReaderSettings()
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("abc", "");
nsmgr.AddNamespace("xyz", "");
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
XmlReader reader = XmlReader.Create(path, settings, context);
|
|
|
|
|
Actually, .NET tells you what is wrong.
According to the XML 1.0 specification, a QName is a qualified or an unqualified name. A qualified name consist of a prefix, and this prefix is a NCName: it cannot contain colons (':').
So what you're asking would not be possible: it's not valid XML to begin with.
See also http://www.w3.org/TR/REC-xml-names/#Conformance[^], where it says :
It follows that in a namespace-well-formed document:
* All element and attribute names contain either zero or one colon;
* No entity names, processing instruction targets, or notation names contain any colons.
Nested XML namespaces are much simpler:
<an:elem><another:one></another:one></an:elem>
|
|
|
|
|
I have a form with a listbox bound to a sql database. I use a dataset to fill the listbox.
I need to have it multiselect and return the data selected. Trying to test this in a messagebox it returns dataview objects and mot the data selected.
Any ideas
Mike
|
|
|
|
|
You need to use the SelectedItems property.
See here.
|
|
|
|
|
Thanks for that reply, I see that and have ammended my code as such, I am making headway though. I can now return the corect amount of selected items but it only returns the top item that many times.
Any ideas from virewing my code.
private void AddData(System.Data.DataRow row, System.Data.DataRow row2)
{
StringBuilder strb = new StringBuilder();
string str1 = "";
object missing = System.Type.Missing;
if ((checkBox1.Checked) || (checkBox2.Checked))
{
MessageBox.Show("There are no rows to insert");
}
else
{
Microsoft.Office.Interop.Word.Selection selection = Globals.ThisDocument.Application.Selection;
int count = Globals.ThisDocument.Tables.Count;
if (selection.Tables.Count > 0)
{
Microsoft.Office.Interop.Word.Row newRow = Globals.ThisDocument.Tables[count].Rows.Add(ref missing);
newRow.Range.Font.Bold = 0;
newRow.Range.ParagraphFormat.Alignment =
Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
newRow.Cells[2].Range.ParagraphFormat.Alignment =
Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
newRow.Cells[1].Range.Text = row["HSActionPlanSubHeader"].ToString();
foreach (DataRowView itm in this.itemDescriptionListBox.SelectedItems)
{
str1 = row2["ItemDescription"].ToString();
strb.Append(str1);
}
newRow.Cells[2].Range.Text = strb.ToString();
}
else
{
MessageBox.Show("Cursor must be within a table.",
"Actions Pane", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
|
|
|
|
|
I did not analyze your code, however this struck me:
surfluds wrote: foreach (DataRowView itm in this.itemDescriptionListBox.SelectedItems)
{
//newRow.Cells[2].Range.Text = row2["ItemDescription"].ToString();
str1 = row2["ItemDescription"].ToString();
strb.Append(str1);
}
itm is enumerating a collection, however you don't use it anywhere???
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Yes thanks Luc, seen that finally, all works as it should. Tired.
|
|
|
|
|
Ok thanks for the reply, got it sorted, stupidly didnot use the correct variable in the foreach loop to reference the dataveiwrow. Couldn't see for looking.
|
|
|
|
|
|
Have you checked the configuration of IIS[^] and you firewall? Did you get any exceptions?
I are Troll
|
|
|
|
|
Hi there,
I know there's no RowDataBound event for the WinForms DataGridView. But there is CellFormatting event in WinForms DataGridView. So Cellformatting event is very very slow.
Is there any solutions like RowDataBound event in WinForms DataGridView (Other then Cellformatting) ?
Thanks for all.
|
|
|
|
|
|
When I create open WPF program examples I see Window1.xaml and a Window1.xaml.cs file
neatly grouped together, the .cs files having a link arrow showing the relation or depency between the two files.
But when I add a xaml file, paste some xml (xaml) into it from another project, I have to
create a separate class file Window1.xaml.cs for example. This file, when added as a new item, is in the same tree hierarchy than the .xaml file and is not showing this arrow icon.
Am I doing something wrong?
--
Christoph
|
|
|
|
|
Make sure they share the same namespaces.....if they do, try reopening your solution again and they should be within the same tree hierarchy.
My signature "sucks" today
|
|
|
|
|
In visual studio if you right click on your project and select "Add"->"New Item" and then select a WPF window, or user control visual studio will automatically add both the xaml and the xaml.cs files which you can paste your code into.
However, if this doesn't suit you, or they somehow become disconnected - which does seem to happen sometimes - you can reattach them like this:
1) Right click on the project and select "Unload project"
2) Now your project is unloaded, right click again and select "Edit [projectname].csproj".
3) This will open the the project file for editing manually, it's just a regular xml file so is fairly easy to read.
4) Search within the xml of the csproj file for the name of your unlinked files.
5) To link a .xaml file with it's child .xaml.cs file it should look something like this:
<Page Include="Window1.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
</Compile>
(You may find that the two files are not next to each other in the .csproj file.)
If they are not correctly linked, you may find that the .xaml.cs reference is missing the dependant tag. If you just added them as regular files, you may also find the tags aren't quite correct.
6) You just need to edit you file to match this layout.
7) Now save the .csproj file. Right click on the project and select "Reload project". You two files should now be linked.
Simon
|
|
|
|
|
I am not very sure of the exact answer. So, I am posting it to find the correct answer.
But i guess Web.config is an xml configuration file. This never gets called directly unless we need to retrieve the configuration setting.
I am not dam sure but i think this should happen.
Reasons are not Important but Results are Important.
http://www.sql4professional.blogspot.com
Swati Tripathi
|
|
|
|
|
Well...yes and no.
It doesn't just hold your own configuration settings, it holds settings for the application so the file will automatically be read every time the application/application pool is restarted and is read into memory. Because of this, every time you change the web.config, the app will do a re-pre-compile to reread it into memory.
So by rights, in ordinary use, it's only really called when the application is started.
That being said, I've had to write custom web.config readers for specific projects but that's my custom code reading the physical file, not the normal operating procedure for the overall project.
|
|
|
|
|
Thanks for your reply but i have one query so pls correct me if i m wrong
This is how the minimal Web.config file should look like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
</system.web>
</configuration>
I do agree that Web.config file is a perfect place to store ASP.NET application configuration settings but if i have above web.config then my other configuration must be in machine.config then how cum web.config called when application pool restarted.
I may be wrong but pls give your glance and guide me ...
Reasons are not Important but Results are Important.
http://www.sql4professional.blogspot.com
Swati Tripathi
|
|
|
|
|
Because as far as I know, you cannot stop a web application from checking web.config. Just because it's empty is no reason for it not to still read it into memory. This is inbuilt behaviour as far as I know.
I also wouldn't use machine.config to hold settings for you. If you are concerned about security, you can encrypt sections of the web.config and the .NET service will decrypt it automatically for you so you don't even need to chagne your code.
|
|
|
|