Click here to Skip to main content
15,867,308 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF Editable ComboxBox Question Pin
Kevin Marois16-Sep-12 9:31
professionalKevin Marois16-Sep-12 9:31 
GeneralRe: WPF Editable ComboxBox Question Pin
SledgeHammer0116-Sep-12 10:15
SledgeHammer0116-Sep-12 10:15 
GeneralRe: WPF Editable ComboxBox Question Pin
Kevin Marois16-Sep-12 10:25
professionalKevin Marois16-Sep-12 10:25 
QuestionWPF Datagrid linked to URL Pin
abollmeyer13-Sep-12 18:14
abollmeyer13-Sep-12 18:14 
AnswerRe: WPF Datagrid linked to URL Pin
Pete O'Hanlon13-Sep-12 20:52
subeditorPete O'Hanlon13-Sep-12 20:52 
GeneralRe: WPF Datagrid linked to URL Pin
abollmeyer13-Sep-12 22:50
abollmeyer13-Sep-12 22:50 
GeneralRe: WPF Datagrid linked to URL Pin
Pete O'Hanlon13-Sep-12 23:23
subeditorPete O'Hanlon13-Sep-12 23:23 
GeneralRe: WPF Datagrid linked to URL Pin
abollmeyer14-Sep-12 21:42
abollmeyer14-Sep-12 21:42 
Hi again Pete,

Sorry it took me so long to respond. I'm actually an Electronics Tech on an oil rig so I got a little busy last night.

My binding was not in the code I provided (sorry!). It was actually in the code-behind, binding to a List collection via a method, so it looked something like this:

partsDataGrid.ItemsSource = LoadCollectionData();


And the method:

private List<addData> LoadCollectionData()
        {
            List<addData> readData = new List<addData>();
            
            //Cannot search by text value of combobox or instant search will be one click behind.
            //Use this code to get "instantaneous" value of combobox text that user has currently selected.
            string searchLine = (machineComboBox.SelectedValue.ToString()).ToUpper();

            string findLine = searchTextBox.Text.ToUpper();

            foreach (string readLine in File.ReadAllLines(path))
            {
                if (readLine.Contains(searchLine) && readLine.Contains(findLine))
                {
                    string[] myData = readLine.Split('|');
            
                    //Add search contents to List array.
                    readData.Add(new addData()
                    {
                        description = myData[0],
                        ICN = myData[1],
                        RIN = myData[2],
                        indexCode = myData[3],
                        location = myData[4],
                        machine = myData[5],
                        webLink = myData[6]
                    });
                }             
            }

            return readData;
        }


From there, I binded the elements of the List to each column of the DataGrid.

I did find a solution to my problem, and it was in the misunderstanding of how a DataGrid actually works (along with how to access a List collection). My bindings were correct for the DataGrid, however, in essence, I wanted to bind two separate pieces of information to one column. As far as I can tell from researching, that is not allowed. And I'm not sure that would be considered good programming if it were.

The solution to my problem was to access the 'webLink' variable in the List separately, and then recall the URL associated with it when I selected the row. The code I used looks something like:

C#
private void partsDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            int index = partsDataGrid.SelectedIndex;

            if (index < 0)
                index = 0;
            else
            {
                string webAddress = ((addData)partsDataGrid.Items[index]).webLink;
            }

        }


As always, I am grateful for your help and appreciate the fact that more experienced programmers are willing to help others who are not quite as smart as they are...yet!

Thank you for the guidance.
QuestionUN Register Scriptable Object Pin
Marc Vandeputte13-Sep-12 7:07
Marc Vandeputte13-Sep-12 7:07 
AnswerRe: UN Register Scriptable Object Pin
Clifford Nelson13-Sep-12 8:34
Clifford Nelson13-Sep-12 8:34 
GeneralRe: UN Register Scriptable Object Pin
Marc Vandeputte13-Sep-12 10:41
Marc Vandeputte13-Sep-12 10:41 
GeneralRe: UN Register Scriptable Object Pin
Clifford Nelson13-Sep-12 11:19
Clifford Nelson13-Sep-12 11:19 
QuestionWCF error - CommunicationException: Error in deserializing body of reply message for operati Pin
vanikanc12-Sep-12 15:33
vanikanc12-Sep-12 15:33 
QuestionWpf Datagrid Pin
sudeep kushwaha12-Sep-12 2:38
sudeep kushwaha12-Sep-12 2:38 
AnswerRe: Wpf Datagrid Pin
Pete O'Hanlon12-Sep-12 3:03
subeditorPete O'Hanlon12-Sep-12 3:03 
GeneralRe: Wpf Datagrid Pin
SledgeHammer0112-Sep-12 11:55
SledgeHammer0112-Sep-12 11:55 
AnswerRe: Wpf Datagrid Pin
Clifford Nelson12-Sep-12 12:19
Clifford Nelson12-Sep-12 12:19 
GeneralRe: Wpf Datagrid Pin
SledgeHammer0112-Sep-12 12:27
SledgeHammer0112-Sep-12 12:27 
AnswerRe: Wpf Datagrid Pin
Clifford Nelson12-Sep-12 12:34
Clifford Nelson12-Sep-12 12:34 
GeneralRe: Wpf Datagrid Pin
SledgeHammer0112-Sep-12 13:29
SledgeHammer0112-Sep-12 13:29 
QuestionWPF groupbox visibility by combobox value selected Pin
karthik bandaru11-Sep-12 20:33
karthik bandaru11-Sep-12 20:33 
AnswerRe: WPF groupbox visibility by combobox value selected Pin
Mycroft Holmes11-Sep-12 20:54
professionalMycroft Holmes11-Sep-12 20:54 
GeneralRe: WPF groupbox visibility by combobox value selected Pin
karthik bandaru11-Sep-12 21:04
karthik bandaru11-Sep-12 21:04 
GeneralRe: WPF groupbox visibility by combobox value selected Pin
Mycroft Holmes11-Sep-12 21:12
professionalMycroft Holmes11-Sep-12 21:12 
QuestionGrid Dynamic Column and Row in run time in WPF MVVM Pin
sels198711-Sep-12 15:59
sels198711-Sep-12 15:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.