Hide Panel depends on Texbox value [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How can I make set a Panel objects visibility to false if the text in a TextBox is "CLOSED"?
My current code is:
if (Session["txtALTN1"] != "Closed")
{
pnlALTN1.Visible = false;
}
else
{
pnlALTN1.Visible = true;
}

Controls are not placed in the session, if txtALTN1 is your TextBox use this instead:
if (txtALTN1.Text != "Closed")
{
pnlALTN1.Visible = false;
}
else
{
pnlALTN1.Visible = true;
}
or simply:
pnlALTN1.Visible = (txtALTN1.Text == "Closed");

Related

How to create and modify custom document properties for office files [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I was following this article, but Office.DocumentProperties throw error that Office does not have DocumentProperties defined.
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
Microsoft.Office.Core.DocumentProperties properties;
var activeDocument = Globals.ThisDocument.Application.ActiveDocument;
properties = (Microsoft.Office.Core.DocumentProperties)activeDocument.CustomDocumentProperties;
MessageBox.Show(JsonConvert.SerializeObject(properties));
}
The How to: Read from and write to document properties article explains how to read from and write to Document Properties. The following code works like a charm on my PC:
Word.Document doc = WordApp.ActiveDocument as Word.Document;
Office.DocumentProperties properties = doc.CustomDocumentProperties as Office.DocumentProperties;
for (int i = 0; i < properties.Count; i++)
{
Office.DocumentProperty property = properties[i];
if(property!=null)
{
System.Windows.Forms.MessageBox.Show(property.Name);
Marshal.ReleaseComObject(property);
}
}
if (properties != null) Marshal.ReleaseComObject(properties);
if (doc != null) Marshal.ReleaseComObject(doc);
Sometimes, you need to use a late-binding technology to avoid exceptions:
dynamic properties = doc.CustomDocumentProperties;

How to find a label in a FlowLayoutPanel [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a c# FlowLayoutPanel container to which I am adding a number of labels with Label.Text set to different values ie Label.Text = "ABCDEF".
What is the best way to search all the labels in the container to find the
a particular label with the Text = "ABCDEF"?
Thank You
You can find the label with text as follow:
foreach (var item in flowLayoutPanel1.Controls)
{
if (item is Label)
{
if ("ASDF" == ((Label)item).Text)
{
MessageBox.Show("found it");
}
}
}
Also if you know your component's name, you can search it as below:
foreach (var item in flowLayoutPanel1.Controls.Find("label1", true))
{
if ("ASDF" == ((Label) item).Text)
{
MessageBox.Show("found it");
}
}

Couldn't find info about creating spellcheck for words with our library in C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I couldn't find any info , about creating a spell checker which reads a word from .txt file.
I will be glad if you can help with anything.
To solve your problem you can use the NHunspell library.
Your check method in this case is very simple and looks like this:
bool CheckSpell(string word)
{
using (Hunspell hunspell = new Hunspell("en_GB.aff", "en_GB.dic"))
{
return hunspell.Spell(word);
}
}
You can find dictionaries on this site.
Also you can use SpellCheck class:
bool CheckSpell(string word)
{
TextBox tb = new TextBox();
tb.Text = word;
tb.SpellCheck.IsEnabled = true;
int index = tb.GetNextSpellingErrorCharacterIndex(0, LogicalDirection.Forward);
if (index == -1)
return true;
else
return false;
}

Trying to understand UI asynchronous calls [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So I found this blog post
http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/
And I've spent the morning trying to learn from it.
It updates a single label with the "stock quote".
MessageBus.Register<QuoteMessage>(m => label1.Text = m.Symbol+":"+m.Quote.ToString("n2"));
I would like to update more than one label with just one message handler. Specifically I might want to change a different label depending on what is in the QuoteMessage object. Given the code below, I can only update the labels with a handler per label.
Doing
MessageBus.Register<QuoteMessage>(m => label1.Text = m.Symbol+":"+m.Quote.ToString("n2"));
MessageBus.Register<QuoteMessage>(m => label2.Text = m.Symbol + ":" + m.Quote.ToString("n2"));
MessageBus.Register<QuoteMessage>(m => label3.Text = m.Symbol + ":" + m.Quote.ToString("n2"));
MessageBus.Register<QuoteMessage>(m => label4.Text = m.Symbol + ":" + m.Quote.ToString("n2"));
just gets me 4 labels displaying the same thing.
I think what you are missing is that the handler can have logic in the delegate action. I would do something like this:
MessageBus.Register<QuoteMessage>(m => {
if (m.Symbol == "MSFT") {
label1.Text = m.Symbol+":"+m.Quote.ToString("n2");
label2.Text = m.Symbol+":"+m.Quote.ToString("n2");
}
else if (something) {
// Do something else
label3.Text = m.Symbol+":"+m.Quote.ToString("n2");
}
});

Simpler way to write this code? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
This is for my button named Edit, when you have an entry into the shopping basket and click on the entry and click Edit it opens up a new window which allows you to edit the entries, product name, quantity or price. This is what I have and it compiles and runs fine but is there an easier way to write it?
private void btn_Edit_Click(object sender, EventArgs e)
{
if (lst_Results.SelectedIndex >= 0)
{
// Want to edit the value of the Item
Edit editbutton = new Edit();
editbutton.NameOfItem =
basket.Items[lst_Results.SelectedIndex].ItemName;
editbutton.Quantity = basket.Items[lst_Results.SelectedIndex].Quantity;
editbutton.ReplacementValue =
basket.Items[lst_Results.SelectedIndex].Price;
if (editbutton.ShowDialog() == DialogResult.OK)
{
basket.UpdateReplacementValue(basket.Items[lst_Results.SelectedIndex].ItemName, editbutton.Quantity, editbutton.ReplacementValue);
RenderLibrary();
}
}
}
At least, you can write out the repeating array access.
// Want to edit the value of the Item
Edit editbutton = new Edit();
var item = basket.Items[lst_Results.SelectedIndex];
editbutton.NameOfItem = item.ItemName;
editbutton.Quantity = item.Quantity;
editbutton.ReplacementValue = item.Price;
if (editbutton.ShowDialog() == DialogResult.OK)
{
basket.UpdateReplacementValue(item.ItemName, editbutton.Quantity, editbutton.ReplacementValue);
RenderLibrary();
}
Also, you might want to just pass the object as parameter to the control, and edit it there using data binding.

Categories

Resources