|
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
|
|
|
|
|
Right, but it would be better to have a method only do one thing, search by ID, or search by Author name.
By storing the value, breaking and then returning, you are just wasting CPU cycles, and memory. Granted it is a rediculously small amount of both, you code isn't more programmer friendly, or easier to read, so where is the justification.
Just suggestions.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
The justification is easy.
Why would you copy & paste a block of code multiple times?
What if the property names on the class changed? Then you have to go through multiple block of code and change it all over.
And you CPU cycles statement doesn't make sense. Splitting the code into 2 methods isn't going to change that.
In some situations, like searching a treeview for a node , you can use either an index or a key value to search for a node.
The exposed method is probably overloaded to accept either datd type, just as my code is doing, then passing the necessary paramater value to a working method.
Everything makes sense in someone's mind
|
|
|
|
|
What if I were to want to extend you function to search on more things?
public Book FindBook(string Name, int ID, string Author, int NumPages, int YearPublished, string Publisher)
Now, you check to see which one I passed and search based on that? No, that is horrible coding practice. If your design requires that you do something like that, redesign.
I am just trying to keep you from coding something that will end up on the Coding Horrors forum.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Truth is, this isn't production code. If it were, and I needed multiple search parameters, I would create a search class with properties for all searchable data elements and a Search method which would return the found item.
Everything makes sense in someone's mind
|
|
|
|