|
Is this going to be the same excel file you'll be opening every time? You could put an 'AutoOpen' macro in the excel file (which would run anytime the file is opened, just enable macros when you open it) to do all this preliminary stuff you're doing in C#. It would be much easier in VBA anyway.
The Code Demon Rises.
|
|
|
|
|
This should do it: Range.Activate Method[^] (Activates a single cell, which must be inside the current selection. To select a range of cells, use the Select method.)
Kind regards,
The only programmers that are better C# programmers, are those who look like this -> |
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi guys!
Maybe someone can help me with this:
I have a library C which controls a device and it's methods take enumerations as parameters.
Then I have a library B which references C and "wraps" the complex commands from library C in something useful and maintainable.
The last thing I have is an assembly A which does the UI stuff. It references ONLY library B.
Nevertheless B needs the values of the enumerations of C to control the device (and to fill comboboxes with the enum-Values)
I need a way to pass the information, which value of an enumeration is needed from A to B.
I do not want to reference C in A (that's how I would get the enumerations as well).
Which would be a good approach to solve this problem.
Help would really be appreciated!
|
|
|
|
|
You could just copy 'n paste the enum .. but that makes it harder to add/change values later (there are probably better solutions..)
|
|
|
|
|
Why not reference C in A? If B references C and A references B, then you have to distribute C with application A anyway. If you want A to have access to the values of the enumeration, referencing C is the 'right' and easiest way to go about it.
|
|
|
|
|
Thanks for your reply. I just hoped it would be possible to separate the C2 logic from the UI with the lib B as link.
|
|
|
|
|
I would put the enum in A; but you could put the enum in D.
|
|
|
|
|
Thanks for the hint, unfortunately I can't do this due to he fact, that lib C wasn't written by me.
|
|
|
|
|
Then write your own in B, and then translate.
|
|
|
|
|
Hi there,
I am quite new to C# and WPF especially. I have a form, with 2 listboxes on. The first looks up an xml file and gets some data items (themes), the next listbox is bound to the first, and gets some data (scenes) from inside the selected theme tag.
This works wonderfully.
I would now like to get the value of an element (FreeStyleCue) and use that in a c# function tied to the OnSelectionChanged handler.
However I cant work out for the life of me how to get the information from the FreeStyleCue tag.
Can anyone help me??
Here is the xml file.
<?xml version="1.0" encoding="utf-8" ?><br />
<themes><br />
<theme name="Yellow" description="A yellow theme" order="1"><br />
<scene name="PreShow" order ="1"><br />
<description>For before the show yellow.</description><br />
<FreeStyleCue>y12</FreeStyleCue><br />
</scene><br />
<scene name="Scenex" order ="1"><br />
<description>During yellow show</description><br />
<FreeStyleCue>y122</FreeStyleCue><br />
</scene><br />
</theme><br />
<theme name="Blue" description="A blue theme" order="1"><br />
<scene name="PreShow" order ="1"><br />
<description>For before the show</description><br />
<FreeStyleCue>b12</FreeStyleCue><br />
</scene><br />
<scene name="Scene1" order ="1"><br />
<description>During Show</description><br />
<FreeStyleCue>b122</FreeStyleCue><br />
</scene><br />
</theme><br />
</themes><br />
Here is the WPF XAML file
<Window x:Class="WpfApplication1.Window1"<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
Title="Window1" Height="400" Width="800"><br />
<Window.Resources><br />
<br />
<XmlDataProvider x:Key="AllThemes" XPath="themes" Source="testdata.xml" /><br />
<br />
<br />
<DataTemplate x:Key="dtThemes"><br />
<br />
<StackPanel FlowDirection="LeftToRight" Orientation="Vertical"><br />
<br />
<TextBlock Text="{Binding XPath=@name}" FontSize="15" /><br />
<TextBlock Text="{Binding XPath=@description}" /><br />
<br />
</StackPanel><br />
<br />
</DataTemplate><br />
<br />
<br />
<DataTemplate x:Key="dtScenes"><br />
<StackPanel FlowDirection="LeftToRight" Orientation="Vertical"><br />
<br />
<TextBlock Text="{Binding XPath=@name}" FontSize="15" /><br />
<TextBlock Text="{Binding XPath=description}" /><br />
<TextBlock Text="{Binding XPath=FreeStyleCue}" /><br />
<br />
</StackPanel><br />
</DataTemplate><br />
<br />
<br />
<br />
</Window.Resources><br />
<br />
<br />
<br />
<Grid Name="gMain"><br />
<Grid.ColumnDefinitions><br />
<ColumnDefinition Width="123" /><br />
<ColumnDefinition Width="8"/><br />
<ColumnDefinition Width="*" /><br />
</Grid.ColumnDefinitions><br />
<br />
<Menu Grid.Column="0" Grid.ColumnSpan="3"></Menu><br />
<br />
<ListBox Name="listboxTheme" <br />
ItemsSource="{Binding Source={StaticResource AllThemes}, XPath=theme}"<br />
ItemTemplate="{StaticResource dtThemes}" HorizontalAlignment="Left" Width="123"><br />
</ListBox><br />
<br />
<GridSplitter Grid.Column="1"></GridSplitter><br />
<br />
<StackPanel Grid.ColumnSpan="2" Margin="6,0,6,0" Grid.Column="1"><br />
<ListBox Name="listboxScenes" <br />
ItemsSource="{Binding ElementName=listboxTheme, Path=SelectedItem, UpdateSourceTrigger=PropertyChanged}" <br />
ItemTemplate="{StaticResource dtScenes}" Height="650" SelectionChanged="listboxScenes_SelectionChanged"><br />
<br />
</ListBox><br />
</StackPanel><br />
<br />
</Grid><br />
</Window><br />
and the code that is asking for the data
<br />
private void listboxScenes_SelectionChanged(object sender, SelectionChangedEventArgs e)<br />
{<br />
<br />
<br />
SelectQueueInFS(SelectionID);
}<br />
<br />
|
|
|
|
|
I give u an example.
I have a ComboBox 'themesComboBox' decalared in XAML file. (Note the x:Name, instead of Name, so that we can refer the ComboBox from C#).
<ComboBox SelectedIndex="0" x:Name="themesComboBox" SelectionChanged="ThemeChanged">
The following is the method which handles the event.
void ThemeChanged(object sender,RoutedEventArgs args)
{
ComboBoxItem cbi =(ComboBoxItem)themesComboBox.SelectedItem;
string themeName = cbi.Content.ToString();
}
Modify the two lines in your program
<TextBlock Text="{Binding XPath=FreeStyleCue}" /> to
<TextBlock Text="{Binding XPath=FreeStyleCue}" x:Name='freeStyeleCueTextBox'/>
<ListBox Name="listboxScenes"
ItemsSource="{Binding ElementName=listboxTheme, Path=SelectedItem, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource dtScenes}" Height="650" SelectionChanged="listboxScenes_SelectionChanged"> to
<ListBox x:Name="listboxScenes"
ItemsSource="{Binding ElementName=listboxTheme, Path=SelectedItem, UpdateSourceTrigger=PropertyChanged}"
ItemTemplate="{StaticResource dtScenes}" Height="650" SelectionChanged="listboxScenes_SelectionChanged">
Now you can access the textbox and list box from your c# code.
Hope it will help you.
|
|
|
|
|
Hi there,
Thanks for the help. Most appreciated!
THe only thing is that I was using XML in the listbox so it outputs XML instead of a string.
I have included
using System.Xml;
and then the code is now
XmlNodeList FSQUES = ((XmlElement)listboxScenes.SelectedItem).GetElementsByTagName("FreeStyleCue");<br />
<br />
foreach (XmlNode FreeStyleCue in FSQUES)<br />
{<br />
SelectQueueInFS(FreeStyleCue.InnerText);<br />
<br />
}
Hope this helps someone.
Reg
|
|
|
|
|
Hi all,
I have added IHtmlscriptElement ( a javascript function )
now i want to attach and event for the body tag
For example,
in the initial
.............
Dynamically i want to add as bellow
.............
How to add as above
Please some one help me
thanks in advance
|
|
|
|
|
do u want from .cs file
thanks ,
amit
|
|
|
|
|
Hi Friend,
thanks, yes i am doing in C# application only
if you guide me it will be much helpful for me.
thanks again
|
|
|
|
|
hi,
from .cs file u can use this I hope this will help u out
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "unSelectCheckbox();", true);
Thanks,
Amit Patel
|
|
|
|
|
Hi Friend,
Thank you,
I am using web browser control, in windows application,
so i get all the HtmlElement like body,form,div etc...
from there i want to attache this.
have a look at my code
mshtml.IHTMLElementCollection ecol = document.all;
if (ecol != null)
{
foreach (IHTMLElement elmnt in ecol)
{
string str = elmnt.outerText;
int k = 0;
if (elmnt.ToString() == "mshtml.HTMLHeadElementClass")
{
mshtml.IHTMLHeadElement head = (mshtml.IHTMLHeadElement)elmnt;
mshtml.IHTMLScriptElement element = (mshtml.IHTMLScriptElement)document.createElement("script");
element.text ="function EventRaise(){var m = document.activeElement.value;alert(document.activeElement.type);alert('The active element is '+m); }";
IHTMLDOMNode node = (IHTMLDOMNode)element;
document.appendChild(node);
}
else if (elmnt.ToString() == "mshtml.HTMLBodyClass")
{
}
}
}
i hope you may have some idea on that...
awaiting...
|
|
|
|
|
|
That image is very small, and i'm not sure i understood your question.
|
|
|
|
|
I may be wrong, but I don't think VS uses a rich text control. I would draw the text myself, especially for such a specific interface and I would expect MS to do the same.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
Yes, I understood that from your original post. You want collapsable regions similar to that implemented in VS.
You will have to code that yourself. There is nothing in the standard toolbox which will do it for you. Look at the Paint event, MeasureText, and DrawText for starters. Be aware, it won't be a trivial task...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi. plz show a sample for me .
|
|
|
|
|
|
ShaktisinhRathod wrote: I am Facing a problem in Word.Document.SaveAs(,)
It Shows Error "No overload for method 'SaveAs' takes '11' arguments"
when I run application on OTHER MACHINE which also using Office2003.
Same Applicaiton works On My machine with 16 arguments
Have you checked you are supplying 16 arguments? Beacuse the error says 11, and the compiler can normally count pretty well...
BTW: when I have to supply lots of arguments to a method, I tend to put them each on a separate line - it make identifying which is which a lot easier, and you can also comment them:
aDoc.SaveAs(ref destFile,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1,
ref missing1);
missing1);
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|