English 中文(简体)
• 如何从世界森林论坛的多科姆博宾获得选定项目的价值
原标题:How to get value of selected item from multicolumn ComboBox in WPF
    <ComboBox Name="ASelect" Width="180" Height="27" SelectedIndex="0" HorizontalContentAlignment="Center" VerticalAlignment="Center" SelectionChanged="ASelect_SelectionChanged">
                 <ComboBoxItem HorizontalContentAlignment="Right" VerticalContentAlignment="Center">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <Image Source="a.png" Height="18" Width="22" />
                        <Label Content=" "/>
                    <TextBlock Width="150" Name="All"> All Values</TextBlock>
                </StackPanel>
                </ComboBoxItem>

                <ComboBoxItem HorizontalContentAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="tick.png" Height="24" Width="24" />
                        <TextBlock Width="150"> New Values</TextBlock>
                    </StackPanel>
                </ComboBoxItem>

                <ComboBoxItem HorizontalContentAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="question.png" Height="24" Width="24" />
                        <TextBlock Width="150"> Old Values</TextBlock>
                    </StackPanel>
                </ComboBoxItem>
</ComboBox>

• 如何从多column combo箱中获取选定项目的价值。 我想得到“所有价值观”的文字24的价值。 我尝试使用以下法典,但把它当作脚石,

string selectionString = ((ComboBoxItem)ASelect.SelectedItem).Content.ToString();
最佳回答

姓名

        <TextBlock Name="m_txtAllValues" Width="150"> All Values</TextBlock>

之后

         m_txtAllValues.Text = "yay it does work";

最新情况:对一味错:

You have a property ASelect.SelectedIndex which indicated which one is selected so you could make a list Collection of your TextBlocks (List or Dictionary f.e) and add your text blocks (named) to it in order 之后

     string txt = myCollectionOfTextBlocks[ASelect.SelectedIndex];
问题回答

你正在增加一个复杂的类型(标签),作为你的 com箱的物品。 当你获得你 com子的选定不动产时,你正在回头看圣卡片物体。

这就是 com箱知道其物品的程度。 它没有任何东西在StackPanel。

和我的朋友一样,你需要以某种方式把视像树推向你们想要的东西。

采取黑板的方式是把StackPanele先生带回来,叫StackPanel。 孩子们,然后让孩子们er,找到你想要的东西。 然而,这种做法非常脆弱,一般不建议。

您真正想要做的是,数据对 com子具有约束力,并将国际交易日志与名单上的数据分开。 这样,你就可以获取你想要的数据(正文箱价值),而不论该项目的结构如何。

请遵循本守则。

string typeID="WHT01";
for (int i = 0; i < cmbWHTypeId.Items.Count; i++)
{
   EWareHouseTypes aWHType = (EWareHouseTypes)cmbWHTypeId.Items[i];
   if (aWHType.WhtID == typeID)
   {
      cmbWHTypeId.SelectedIndex = i;
      break;
   }
}

http://refat38.wordpress.com/02/18/multi-column-combo Box-in-c-wpf/“rel=“nofollow”>





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签