문제

C# 코딩 된 응용 프로그램은 infragistics.win.ultrawingrid.ultragrid를 사용하여 일부 데이터를 표시합니다. 데이터는 기본적으로 컴퓨터 모음입니다. 응용 프로그램은 볼 수 있도록 이러한 컴퓨터 ( "워크 스테이션", "서버"등)를 필터링 할 수 있습니다. 이것이 내가 필터링하는 방법입니다.

private DataView FilterTableDataForViewing(DataTable originalTable, string filterString, UltraGrid viewGrid)
    {
        DataView dataView = new DataView(originalTable);
        dataView.RowStateFilter = DataViewRowState.CurrentRows;
        dataView.RowFilter = filterString;

        DataTable filteredTable = dataView.ToTable(originalTable.TableName + "_" + dataView.RowFilter);
        viewGrid.DataSource = filteredTable;
        gridDiscoveryMain.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
        SetFlagImagesAndColumnWidthsOfDiscoveryGrid();
        return dataView;
    }

테이블 이름을 잠재적으로 거대한 필터 문자열로 설정했습니다.

이것이 위의 방법을 사용하는 방법입니다.

string filterString = "([Build] = '4.0' AND NOT([OS Plus Version] LIKE '%Server%'))";
            filterString += " OR ([Build] = '4.10')";
            filterString += " OR ([Build] = '4.90')";
            filterString += " OR ([Build] = '5.0' AND NOT([OS Plus Version] LIKE '%Server%'))";
            filterString += " OR ([Build] = '5.1')";
            filterString += " OR ([Build] = '6.0' AND ";
            filterString += "(NOT([OS Plus Version] LIKE '%Server%')) OR (NOT([OS] LIKE '%Server%')))";
            FilterTableDataForViewing(dataSet.Tables["DiscoveryData"], filterString, gridDiscoveryMain);

그 시점까지 모든 것이 괜찮습니다. UltraGrids에는 숨겨져 원하는 열을 선택하고 새 사용자 정의 열을 만들 수있는 시설이 있습니다. 이 시설이 시작되면 Ultragrid라는 이벤트가 시작됩니다. BeforeColumnChooserDisplayed 해고되었습니다. 여기 내 핸들러가 있습니다.

private void gridDiscoveryMain_BeforeColumnChooserDisplayed(object sender, BeforeColumnChooserDisplayedEventArgs e)
    {
        if (gridDiscoveryMain.DataSource == null)
            return;

        e.Cancel = true;
        gridDiscoveryMain.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;
        gridDiscoveryMain.DisplayLayout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton;
        ShowCustomColumnChooserDialog();
        this.customColumnChooserDialog.CurrentBand = e.Dialog.ColumnChooserControl.CurrentBand;
        this.customColumnChooserDialog.ColumnChooserControl.Style = ColumnChooserStyle.AllColumnsWithCheckBoxes;
    }

그리고 여기에 있습니다 ShowCustomColumnChooserDialog 방법 구현 :

private void ShowCustomColumnChooserDialog()
    {
        DataTable originalTable = GetUnderlyingDataSource(gridDiscoveryMain);
        if (this.customColumnChooserDialog == null || this.customColumnChooserDialog.IsDisposed)
        {
            customColumnChooserDialog = new CustomColumnChooser(ManageColumnDeleted);
            customColumnChooserDialog.Owner = Parent.FindForm();
            customColumnChooserDialog.Grid = gridDiscoveryMain;
        }

        this.customColumnChooserDialog.Show();
    }

CustomColumnChooserDialog는 기본적으로 Infragistics 기본값에 약간의 추가 기능을 추가하는 양식입니다. 코드를 처리하는 가장 중요한 것은이 방법입니다.

private void InitializeBandsCombo( UltraGridBase grid )
    {
        this.ultraComboBandSelector.SetDataBinding( null, null );
        if ( null == grid )
            return;

        // Create the data source that we can bind to UltraCombo for displaying 
        // list of bands. The datasource will have two columns. One that contains
        // the instances of UltraGridBand and the other that contains the text
        // representation of the bands.
        UltraDataSource bandsUDS = new UltraDataSource( );
        bandsUDS.Band.Columns.Add( "Band", typeof( UltraGridBand ) );
        bandsUDS.Band.Columns.Add( "DisplayText", typeof( string ) );

        foreach ( UltraGridBand band in grid.DisplayLayout.Bands )
        {
            if ( ! this.IsBandExcluded( band ) )
            {
                bandsUDS.Rows.Add( new object[] { band, band.Header.Caption } );
            }
        }

        this.ultraComboBandSelector.DisplayMember = "DisplayText";
        this.ultraComboBandSelector.ValueMember= "Band";
        this.ultraComboBandSelector.SetDataBinding( bandsUDS, null );

        // Hide the Band column.
        this.ultraComboBandSelector.DisplayLayout.Bands[0].Columns["Band"].Hidden = true;

        // Hide the column headers.
        this.ultraComboBandSelector.DisplayLayout.Bands[0].ColHeadersVisible = false;

        // Set some properties to improve the look & feel of the ultra combo.
        this.ultraComboBandSelector.DropDownWidth = 0;
        this.ultraComboBandSelector.DisplayLayout.Override.HotTrackRowAppearance.BackColor = Color.LightYellow;
        this.ultraComboBandSelector.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
        this.ultraComboBandSelector.DisplayLayout.BorderStyle = UIElementBorderStyle.Solid;
        this.ultraComboBandSelector.DisplayLayout.Appearance.BorderColor = SystemColors.Highlight;
    }

코드를 밟으면 이벤트 핸들러 (컨트롤이 양식으로 돌아 오는 지점)를 종료 할 때까지 모두 멋지다. 나는 나에게 인수를 던진 인수를 얻는다 표시되는 그리드에서 CustomColumnChooser 대화 상자를 표시 할 때 필터링 된 데이터. 코드에 문제가있는 줄을 보여주는 종류가 아니라 "Microsoft .NET Framework"오류 메시지 상자를 가져 오는 유형은 "응용 프로그램에서 처리되지 않은 예외가 발생했습니다 ...". 이것은 내가 원인을 추적 할 수 없다는 것을 의미합니다. 그 후 앱은 무너지지 않지만 CustomColumnChooser 대화 상자는 흰색 배경과 큰 빨간색 "x"만 포함 된 컨테이너가 제공됩니다.

그리고 스택 추적 :

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Child list for field DiscoveryData_([Build] = '4 cannot be created.
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.EnsureListManager(Object dataSource, String dataMember)
   at System.Windows.Forms.BindingContext.get_Item(Object dataSource, String dataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated()
   at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBindingHelper(Object dataSource, String dataMember, Boolean hideNewColumns, Boolean hideNewBands)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember, Boolean hideNewColumns, Boolean hideNewBands)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember, Boolean hideNewColumns)
   at Infragistics.Win.UltraWinGrid.UltraGridBase.SetDataBinding(Object dataSource, String dataMember)
   at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.CreateColumnChooserGridDataStructure()
   at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.Initialize()
   at Infragistics.Win.UltraWinGrid.UltraGridColumnChooser.VerifyInitialized()
   at Infragistics.Win.UltraWinGrid.ColumnChooserGridCreationFilter.BeforeCreateChildElements(UIElement parent)
   at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive)
   at Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.InternalInitializeRect(Boolean verify)
   at Infragistics.Win.UltraWinGrid.UltraGridLayout.GetUIElement(Boolean verify, Boolean forceInitializeRect)
   at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Field DiscoveryData의 자식 목록 ([build] = '4를 만들 수 없습니다. 그다지 도움이되지 않습니다. 정말 무슨 뜻인가요?

도움이 되었습니까?

해결책

나는 Winforms에 너무 잘 맞지 않으며 Infragistics Ultragrid를 사용한 적이 없습니다. 내 추측은 그렇게 될 것입니다 Field DiscoverData의 자식 목록 ([build] = '4 일부 데이터 바인딩 코드의 프레임 워크에 깊이 버려집니다. 그것은 전화 수업의 자녀를 찾고있는 것 같습니다. ([빌드] = '4 문자열 문자에서 점 또는 기간 (.)에서 멈출 때.

나는 함께 일하는 것을 피하려고 노력합니다 DataSet모래 DataViewS 미친 후프 중 일부는 그들이 뛰어 다니고 있습니다.

반사기를 발사하고 주위에 찌르는 가치가있을 수 있습니다. System.Windows.Forms.BindingContext

다른 팁

데이터 재사용을 확인하십시오.

구속력으로 인해 문제가 발생합니다. 다음과 같은 것이 있다면 :

labelFirstName.DataBindings.Add("Text", "_Person.Info.FName", true, DataSourceUpdateMode.OnPropertyChanged);

아마도 다른 추가 방법 오버로드로 업데이트해야 할 것입니다.

labelFirstName.DataBindings.Add("Text", _Person.Info, "FName", true, DataSourceUpdateMode.OnPropertyChanged);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top