|
Is the IExcel interface also something you created? You really should implement this using IDisposable as well. Take a look at this article[^] for more information.
I'm not sure why you are getting different behavior when calling this on the interface instance as that shouldn't cause any problems. Try changing your code to implement the dispose pattern and see if you get any better behavior. (Even if you don't, you will still be in a better position as you are working with the GC in a much better manner.)
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
[ Blog][ Articles][ Forum Guidelines] Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
|
|
|
|
|
I just moved a project of mine from the Express edition of Web Developer 2008 to VS 2008, and i have an odd issue. I have a class that was previously that had no namespace before, as with several other classes in the project. Since adding them all to the project, I have added them all to the namespace of the project, we'll say MarvelUniverse for the purposes of the post. Now, every other class works just fine, but the class MarvelSQL is not showing up or available.
It is a public partial class generated with sqlmetal, but aside from that, it is identical to the other classes, and even the other public partial classes (including the page classes, like _Default, are visible...)
Any ideas? This has been driving me nuts...
______________________
Oh Hamburgers!
|
|
|
|
|
Here's my problem. I have this line of code in an unsafe context:
TreeNode* Current = null;
it gives me an error that says "Cannot take the address of, get the size of, or declare a pointer to a managed type ("System.Windows.Forms.TreeNode")"
The C++ equivalent of that line would be
System::Windows::Forms::TreeNode *Current = 0;
and in C++, i can avoid that error by using the '^' operator like so
System::Windows::Forms::TreeNode^ *Current = 0;
however, i know little to nothing about C++, and i have no idea what the '^' operator does. If anyone knows a way to implement this in C#, please let me know.
void Play() { try { throw Ball(); } catch (Glove) { } finally { Play(); } }
"Failure is only the opportunity to begin again, this time more wisely."
"Don't ask for a light load, but rather ask for a strong back."
|
|
|
|
|
C++ won't help here.
You can't take the address of a managed object in either language.
In C++/CLI, ^ indicates a handle to a managed object. You can get the
address of the handle but not the address of the object.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
To get a pointer to an object on the heap, you have to fix in to a specific address so that the garbage collector is no longer allowed to move it around in memory:
fixed (TreeNode* Current = null) {
}
Why do you need a pointer to a TreeNode anyway?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Pros, I have a question that is I am custom drawing the listbox items. What i want an i-beam/or cursor to be blink between each items. So if say there are 4 items and I click between item 2 and 3 the i-beam should be flashing between item 2 and 3. Is there any way to do get this sort of result.
I appreciate your inputs. Thanks
|
|
|
|
|
If you want to control mouse cursor, I think you have two possibilities:
- use I-beam cursor (Cursor.Current Property [^]) and Cursor.Hide Method[^] via timer
- create your own animated cursor. However, .Net framework does not support animated cursors directly so I believe you should use non-managed code in this case
Mika
|
|
|
|
|
I need to get list of all fields referenced in RDL report.
It seems that Field references are prefixed with Fields! prefix
Field name constains letters, number and underscores.
RDL format is XML, sample below.
Maybe simplest is to treat it as txt file and parse character by character:
1. Find all characters containing Fields!
2. Extract identifier after Fields! characters
Result from file below should be:
Continent
Name
Code
...
Any idea how to implement this ?
Andrus.
<?xml version="1.0" encoding="UTF-8"?>
<Report Name="WorldFacts">
<Description>Worlds Facts - test data from MySQL World database</Description>
<DataElementStyle>ElementNormal</DataElementStyle>
<LeftMargin>.4in</LeftMargin>
<RightMargin>.4in</RightMargin>
<TopMargin>.5in</TopMargin>
<BottomMargin>.5in</BottomMargin>
<DataSources>
<DataSource Name="DS1">
<ConnectionProperties>
<DataProvider>xxx</DataProvider>
<!-- Use this line when using xml data -->
<ConnectString>dsn=world;UID=uuu;PWD=ppp;</ConnectString>
</ConnectionProperties>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="Data">
<Query>
<DataSourceName>DS1</DataSourceName>
<!-- <CommandText>SELECT Code, Name, Continent, Region, Population, IndepYear, SurfaceArea FROM Country</CommandText> -->
</Query>
<Fields>
<Field Name="Code">
<DataField>Code</DataField>
<TypeName>String</TypeName>
</Field>
<Field Name="Name">
<DataField>Name</DataField>
<TypeName>String</TypeName>
</Field>
<Field Name="Continent">
<DataField>Continent</DataField>
<TypeName>String</TypeName>
</Field>
<Field Name="Region">
<DataField>Region</DataField>
<TypeName>String</TypeName>
</Field>
<Field Name="Population">
<DataField>Population</DataField>
<TypeName>Float</TypeName>
</Field>
<Field Name="IndependenceYear">
<DataField>IndependenceYear</DataField>
<TypeName>Float</TypeName>
</Field>
<Field Name="SurfaceArea">
<DataField>SurfaceArea</DataField>
<TypeName>Float</TypeName>
</Field>
</Fields>
<Rows File="WorldFacts.xml" />
</DataSet>
</DataSets>
<PageHeader>
<Height>.5 in</Height>
<ReportItems>
<Textbox Name="Textbox1">
<Top>.1 in</Top>
<Left>.1 in</Left>
<Height>.25 in</Height>
<Value>The World's Countries</Value>
<Style>
<FontSize>15pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
<PrintOnFirstPage>True</PrintOnFirstPage>
<PrintOnLastPage>True</PrintOnLastPage>
</PageHeader>
<Body>
<Height>64.4pt</Height>
<ReportItems>
<Table Name="Table1">
<DetailDataElementName>Row</DetailDataElementName>
<DetailDataCollectionName>Rows</DetailDataCollectionName>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<TableColumns>
<TableColumn>
<Width>.75 in</Width>
</TableColumn>
<TableColumn>
<Width>.5 in</Width>
</TableColumn>
<TableColumn>
<Width>2.5 in</Width>
</TableColumn>
<TableColumn>
<Width>1 in</Width>
</TableColumn>
<TableColumn>
<Width>1 in</Width>
</TableColumn>
<TableColumn>
<Width>1 in</Width>
</TableColumn>
<TableColumn>
<Width>1 in</Width>
</TableColumn>
</TableColumns>
<Header>
<TableRows>
<TableRow>
<Height>12 pt</Height>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="Textbox2">
<Value>Continent</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox3">
<Value>Code</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox4">
<Value>Name</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox5">
<Value>Region</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox6">
<Value>Population</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox7">
<Value>Independence</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox8">
<Value>Surface Area</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
<RepeatOnNewPage>true</RepeatOnNewPage>
</Header>
<TableGroups>
<TableGroup>
<Header>
<TableRows>
<TableRow>
<Height>12 pt</Height>
<TableCells>
<TableCell>
<ColSpan>7</ColSpan>
<ReportItems>
<Textbox Name="Textbox9">
<Value>=Fields.Continent.Value</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
<RepeatOnNewPage>true</RepeatOnNewPage>
</Header>
<Footer>
<TableRows>
<TableRow>
<Height>12 pt</Height>
<TableCells>
<TableCell>
<ColSpan>7</ColSpan>
<ReportItems>
<Textbox Name="Textbox14">
<Value>="Count of countries in " + Fields.Continent.Value + " = " +Count(Fields.Name.Value)</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
</Footer>
<Grouping Name="ContinentGroup">
<GroupExpressions>
<GroupExpression>=Fields!Continent.Value</GroupExpression>
</GroupExpressions>
</Grouping>
</TableGroup>
</TableGroups>
<Details>
<Sorting>
<SortBy>
<SortExpression>=Fields!Name.Value</SortExpression>
</SortBy>
</Sorting>
<TableRows>
<TableRow>
<Height>12 pt</Height>
<TableCells>
<TableCell>
<ReportItems>
<Textbox Name="Textbox10">
<Value>
</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
<Bottom>None</Bottom>
<Top>None</Top>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Code">
<Value>=Fields!Code.Value</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Name">
<CanGrow>true</CanGrow>
<Value>=Fields!Name.Value</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Region">
<CanGrow>true</CanGrow>
<Value>=Fields!Region.Value</Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox11">
<Value>=Fields!Population.Value</Value>
<Style>
<Format>#,##0</Format>
<TextAlign>Right</TextAlign>
<PaddingRight>2 pt</PaddingRight>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox12">
<Value>=switch(Fields!IndependenceYear.Value = 0, "", Fields!IndependenceYear.Value > 0, Fields!IndependenceYear.Value, true, -Fields!IndependenceYear.Value + " BC")</Value>
<Style>
<Format>0000</Format>
<TextAlign>Center</TextAlign>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ReportItems>
<Textbox Name="Textbox13">
<Value>=Fields!SurfaceArea.Value</Value>
<Style>
<Format>#,##0</Format>
<TextAlign>Right</TextAlign>
<PaddingRight>2 pt</PaddingRight>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
</Details>
<Footer>
<TableRows>
<TableRow>
<Height>12 pt</Height>
<TableCells>
<TableCell>
<ColSpan>4</ColSpan>
<ReportItems>
<Textbox Name="Textbox15">
<Value>=CountDistinct(Fields.Continent.Value) + " continents. " + Count(Fields.Name.Value)+ " countries." </Value>
<Style>
<PaddingLeft>2 pt</PaddingLeft>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ColSpan>1</ColSpan>
<ReportItems>
<Textbox Name="Textbox16">
<Value>=Sum(Fields.Population.Value)</Value>
<Style>
<Format>#,##0</Format>
<TextAlign>Right</TextAlign>
<PaddingRight>2 pt</PaddingRight>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ColSpan>1</ColSpan>
<ReportItems>
<Textbox Name="Textbox17">
<Value>
</Value>
<Style>
<Format>#,##0</Format>
<TextAlign>Right</TextAlign>
<PaddingRight>2 pt</PaddingRight>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
<TableCell>
<ColSpan>1</ColSpan>
<ReportItems>
<Textbox Name="Textbox18">
<Value>=Sum(Fields.SurfaceArea.Value)</Value>
<Style>
<Format>#,##0</Format>
<TextAlign>Right</TextAlign>
<PaddingRight>2 pt</PaddingRight>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
<FontWeight>Bold</FontWeight>
</Style>
</Textbox>
</ReportItems>
</TableCell>
</TableCells>
</TableRow>
</TableRows>
</Footer>
</Table>
</ReportItems>
<Columns>1</Columns>
</Body>
<PageFooter>
<Height>0pt</Height>
<PrintOnFirstPage>True</PrintOnFirstPage>
<PrintOnLastPage>True</PrintOnLastPage>
</PageFooter>
<Width>7in</Width>
<PageWidth>8.5in</PageWidth>
<PageHeight>11in</PageHeight>
<DataElementName>Report</DataElementName>
</Report>
Andrus
|
|
|
|
|
Try reading the file into XmlDocument class and then use SelectNodes method (querying for 'Field'). After this you should have a node list and you can extract Name attribute for each node.
Mika
|
|
|
|
|
I havent never used this.
Can you provide come example ?
node values can contain expressions like
Fields!myfield + "Fields!ddddd"
from this expression I need to extract only
myfield name.
How to extract field names from node values ?
Andrus
|
|
|
|
|
This should get you going.
string xmlText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Report Name=\"WorldFacts\"> <Description>Worlds Facts - test data from MySQL World database</Description> <DataElementStyle>ElementNormal</DataElementStyle> <LeftMargin>.4in</LeftMargin> <RightMargin>.4in</RightMargin> <TopMargin>.5in</TopMargin> <BottomMargin>.5in</BottomMargin> <DataSources> <DataSource Name=\"DS1\"> <ConnectionProperties> <DataProvider>xxx</DataProvider> <!-- Use this line when using xml data --> <ConnectString>dsn=world;UID=uuu;PWD=ppp;</ConnectString> </ConnectionProperties> </DataSource> </DataSources> <DataSets> <DataSet Name=\"Data\"> <Query> <DataSourceName>DS1</DataSourceName> <!-- <CommandText>SELECT Code, Name, Continent, Region, Population, IndepYear, SurfaceArea FROM Country</CommandText> --> </Query> <Fields> <Field Name=\"Code\"> <DataField>Code</DataField> <TypeName>String</TypeName> </Field> <Field Name=\"Name\"> <DataField>Name</DataField> <TypeName>String</TypeName> </Field> <Field Name=\"Continent\"> <DataField>Continent</DataField> <TypeName>String</TypeName> </Field> <Field Name=\"Region\"> <DataField>Region</DataField> <TypeName>String</TypeName> </Field> <Field Name=\"Population\"> <DataField>Population</DataField> <TypeName>Float</TypeName> </Field> <Field Name=\"IndependenceYear\"> <DataField>IndependenceYear</DataField> <TypeName>Float</TypeName> </Field> <Field Name=\"SurfaceArea\"> <DataField>SurfaceArea</DataField> <TypeName>Float</TypeName> </Field> </Fields> <Rows File=\"WorldFacts.xml\" /> </DataSet> </DataSets> <PageHeader> <Height>.5 in</Height> <ReportItems> <Textbox Name=\"Textbox1\"> <Top>.1 in</Top> <Left>.1 in</Left> <Height>.25 in</Height> <Value>The World's Countries</Value> <Style> <FontSize>15pt</FontSize> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> <PrintOnFirstPage>True</PrintOnFirstPage> <PrintOnLastPage>True</PrintOnLastPage> </PageHeader> <Body> <Height>64.4pt</Height> <ReportItems> <Table Name=\"Table1\"> <DetailDataElementName>Row</DetailDataElementName> <DetailDataCollectionName>Rows</DetailDataCollectionName> <Style> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> <TableColumns> <TableColumn> <Width>.75 in</Width> </TableColumn> <TableColumn> <Width>.5 in</Width> </TableColumn> <TableColumn> <Width>2.5 in</Width> </TableColumn> <TableColumn> <Width>1 in</Width> </TableColumn> <TableColumn> <Width>1 in</Width> </TableColumn> <TableColumn> <Width>1 in</Width> </TableColumn> <TableColumn> <Width>1 in</Width> </TableColumn> </TableColumns> <Header> <TableRows> <TableRow> <Height>12 pt</Height> <TableCells> <TableCell> <ReportItems> <Textbox Name=\"Textbox2\"> <Value>Continent</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox3\"> <Value>Code</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox4\"> <Value>Name</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox5\"> <Value>Region</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox6\"> <Value>Population</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox7\"> <Value>Independence</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox8\"> <Value>Surface Area</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> </TableCells> </TableRow> </TableRows> <RepeatOnNewPage>true</RepeatOnNewPage> </Header> <TableGroups> <TableGroup> <Header> <TableRows> <TableRow> <Height>12 pt</Height> <TableCells> <TableCell> <ColSpan>7</ColSpan> <ReportItems> <Textbox Name=\"Textbox9\"> <Value>=Fields.Continent.Value</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> </TableCells> </TableRow> </TableRows> <RepeatOnNewPage>true</RepeatOnNewPage> </Header> <Footer> <TableRows> <TableRow> <Height>12 pt</Height> <TableCells> <TableCell> <ColSpan>7</ColSpan> <ReportItems> <Textbox Name=\"Textbox14\"> <Value>=\"Count of countries in \" + Fields.Continent.Value + \" = \" +Count(Fields.Name.Value)</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> </TableCells> </TableRow> </TableRows> </Footer> <Grouping Name=\"ContinentGroup\"> <GroupExpressions> <GroupExpression>=Fields!Continent.Value</GroupExpression> </GroupExpressions> </Grouping> </TableGroup> </TableGroups> <Details> <Sorting> <SortBy> <SortExpression>=Fields!Name.Value</SortExpression> </SortBy> </Sorting> <TableRows> <TableRow> <Height>12 pt</Height> <TableCells> <TableCell> <ReportItems> <Textbox Name=\"Textbox10\"> <Value> </Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> <Bottom>None</Bottom> <Top>None</Top> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Code\"> <Value>=Fields!Code.Value</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Name\"> <CanGrow>true</CanGrow> <Value>=Fields!Name.Value</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Region\"> <CanGrow>true</CanGrow> <Value>=Fields!Region.Value</Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox11\"> <Value>=Fields!Population.Value</Value> <Style> <Format>#,##0</Format> <TextAlign>Right</TextAlign> <PaddingRight>2 pt</PaddingRight> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox12\"> <Value>=switch(Fields!IndependenceYear.Value = 0, \"\", Fields!IndependenceYear.Value > 0, Fields!IndependenceYear.Value, true, -Fields!IndependenceYear.Value + \" BC\")</Value> <Style> <Format>0000</Format> <TextAlign>Center</TextAlign> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ReportItems> <Textbox Name=\"Textbox13\"> <Value>=Fields!SurfaceArea.Value</Value> <Style> <Format>#,##0</Format> <TextAlign>Right</TextAlign> <PaddingRight>2 pt</PaddingRight> <BorderStyle> <Default>Solid</Default> </BorderStyle> </Style> </Textbox> </ReportItems> </TableCell> </TableCells> </TableRow> </TableRows> </Details> <Footer> <TableRows> <TableRow> <Height>12 pt</Height> <TableCells> <TableCell> <ColSpan>4</ColSpan> <ReportItems> <Textbox Name=\"Textbox15\"> <Value>=CountDistinct(Fields.Continent.Value) + \" continents. \" + Count(Fields.Name.Value)+ \" countries.\" </Value> <Style> <PaddingLeft>2 pt</PaddingLeft> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ColSpan>1</ColSpan> <ReportItems> <Textbox Name=\"Textbox16\"> <Value>=Sum(Fields.Population.Value)</Value> <Style> <Format>#,##0</Format> <TextAlign>Right</TextAlign> <PaddingRight>2 pt</PaddingRight> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ColSpan>1</ColSpan> <ReportItems> <Textbox Name=\"Textbox17\"> <Value> </Value> <Style> <Format>#,##0</Format> <TextAlign>Right</TextAlign> <PaddingRight>2 pt</PaddingRight> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> <TableCell> <ColSpan>1</ColSpan> <ReportItems> <Textbox Name=\"Textbox18\"> <Value>=Sum(Fields.SurfaceArea.Value)</Value> <Style> <Format>#,##0</Format> <TextAlign>Right</TextAlign> <PaddingRight>2 pt</PaddingRight> <BorderStyle> <Default>Solid</Default> </BorderStyle> <FontWeight>Bold</FontWeight> </Style> </Textbox> </ReportItems> </TableCell> </TableCells> </TableRow> </TableRows> </Footer> </Table> </ReportItems> <Columns>1</Columns> </Body> <PageFooter> <Height>0pt</Height> <PrintOnFirstPage>True</PrintOnFirstPage> <PrintOnLastPage>True</PrintOnLastPage> </PageFooter> <Width>7in</Width> <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> <DataElementName>Report</DataElementName></Report>";
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlNodeList selectedNodes;
xmlDoc.LoadXml(xmlText);
selectedNodes = xmlDoc.SelectNodes("Report/DataSets/DataSet/Fields/Field");
foreach (System.Xml.XmlNode xmlNode in selectedNodes) {
System.Windows.Forms.MessageBox.Show(xmlNode.Attributes["Name"].Value);
}
|
|
|
|
|
This selects <fields> elements.
I want to select identifiers inside expressions which are after Field!
characters.
Field elements does not contain expressions.
Expresions are in TextBox Value tags, in Table Group and sort tags etc.
Andrus
|
|
|
|
|
Ok, I understood that you wanted the name attribute.
If you change the message box inside the loop from
System.Windows.Forms.MessageBox.Show(xmlNode.Attributes["Name"].Value);
to
System.Windows.Forms.MessageBox.Show((xmlNode.SelectNodes("DataField")[0]).InnerText);
you can see one way to select inner elements from the xml.
Hope this helps,
Mika
|
|
|
|
|
culd anyone please help me with code for venue booking in Visual basic .net
|
|
|
|
|
masosha wrote: culd anyone please help me with code for venue booking in Visual basic .net
Perhaps somebody in a more appropriate forum - such as the VB.NET forum[^].
|
|
|
|
|
...or perhaps he should try a more appropriate site such as rentacoder.com
masosha, the idea is YOU write some code and when it fails post a question here and someone will try to help
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Yes.
The help I can offer comes in two parts.
First, post in the right forum.
Second, give us the code you need help with, and we can help you with it.
If you need help fixing your car you don't expect me to give you the car to fix do you?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Expert Coming wrote: If you need help fixing your car you don't expect me to give you the car to fix do you?
PERFECT.............and sounds more feasible too...........
|
|
|
|
|
If only people would do that. That would be nice.
Come to think of it, I need help fixing my Jet, and Lambo.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
|
I have created a class called Book:
public class Book
{
public int iBookId = 0;
public String sAuthor = "";
}
Next I load instances of the Book class into an ArrayList. I then have an overloaded method to search for a book by Name or Id.
private static Book _FindBook(int iBookIdToFind, String sNameToFind)
{
Book bookReturn = null;
Book bookArrayBook = null;
int iTotalBooks = books.Count;
for (int iBook = 0; iBook < iTotalBooks; iBook++)
{
bookArrayBook = books[iBook];
if (iBookIdToFind != 0)
{
if (bookArrayBook.iBookId == iBookIdToFind)
{
bookReturn = bookArrayBook;
break;
}
}
else
if (bookArrayBook.sAuthor.ToLower() == sNameToFind.ToLower())
{
bookReturn = bookArrayBook;
break;
}
}
return bookReturn;
}
On this line
bookArrayBook = books[iBook];
I get the error "Cannot implicitly convert type 'object' to 'Book'".
I don't understand this. The object in the collection is already a book.
Anyone?
Everything makes sense in someone's mind
|
|
|
|
|
where do you define your books array? It seems that it's a collection of object rather than an array of book but you haven't posted that part of your code.
Edit: instead of using an ArrayList why not use:
System.Collections.Generic.List<book> books = new System.Collections.Generic.List<book>(); ?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I'm using a class-level ArrayList, so at the top I have:
private static ArrayList books;
Then in another method I load the collection using:
Book Book1 = new Book();
Book1.iBookId = 15;
Book1.sAuthor = "George Washington";
books.Add(Book1);
But my original question is still unanswered. The collection is holding references to a Book class, so why is the compiler complaining?
Everything makes sense in someone's mind
|
|
|
|
|
You should not have one method do two things. Split FindBook into two methods, FindBookByID, and FindBookByName.
Also, since you are not returning more than one result(i.e. only returning one book) don't store it and then return, just return as soon as you find a result. This way you don't loop through the rest of the books for no reason.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
The method onlny DOES do one thing. It searches the collection for a book.
It's private and only called by one of these 2 methods:
public static Book FindBook(int iBookId)
{
return _FindBook(iBookId, "");
}
public static Book FindBook(String sAuthor)
{
return _FindBook(0, sAuthor);
}
Also, notice that in my original positing, once the book is found, it does a Break and drops out the to bottom, where the book is returned. This is in keeping with sound programming which calls for only 1 return from a method.
Everything makes sense in someone's mind
|
|
|
|