当前位置: 首页>>代码示例>>C#>>正文


C# BindingSource.Find方法代码示例

本文整理汇总了C#中System.Windows.Forms.BindingSource.Find方法的典型用法代码示例。如果您正苦于以下问题:C# BindingSource.Find方法的具体用法?C# BindingSource.Find怎么用?C# BindingSource.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.BindingSource的用法示例。


在下文中一共展示了BindingSource.Find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EventProcessing

        private void EventProcessing(int colIndex, int rowIndex, BindingSource actualEvents, BindingSource actualActions)
        {
            try
            {
                //запомнить положение скроллбара
                int saveRow = 0;
                if (dgv1.Rows.Count > 0)
                    saveRow = dgv1.FirstDisplayedCell.RowIndex;

                int currEvent = 0;

                //проверка пересечения мероприятий
                string cellTag = Convert.ToString(dgv1[colIndex, rowIndex].Tag);

                if (Int32.TryParse(cellTag, out currEvent))
                {

                    if ((dgv1.collapseEvents.Keys.Contains(currEvent)) && (dgv1[colIndex, rowIndex].Style.BackColor == event_error_bg))
                    {
                        string filter = String.Format("[{0}] IN ({1}, {2})", currEventField, currEvent, dgv1.collapseEvents[currEvent]);
                        CollapseSelect cs = new CollapseSelect(filter, eCategory);

                        if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            currEvent = cs.ReturnEventID();
                        }
                        else
                            return;
                    }

                    actualEvents.Position = actualEvents.Find(currEventField, currEvent);

                    DataRowView curr = (DataRowView)actualEvents.Current;
                    DateTime ebegin = Convert.ToDateTime(Convert.ToString(curr["BeginTime"]));
                    DateTime eend = Convert.ToDateTime(Convert.ToString(curr["EndTime"]));
                    //if (this.EditCurrentEvent(actualEvents, this.eventlistBindingSource, ebegin, eend))
                    //выбираем кейсом eCategory и создаем IEditable;

                    IEditable editEventForm = null;
                    IEditable editActionForm = null;

                    switch (eCategory)
                    {
                        case eventCategory.CurrentEvent:
                            {
                                editEventForm = new EditEventItem(actualEvents, this.eventlistBindingSource, ebegin, eend);
                                editActionForm = new EditActionItem(actualActions, actualEvents, facility_tracksBindingSource,
            groupsBindingSource, group_headersBindingSource);
                            }
                            break;
                        case eventCategory.CalendarEvent:
                            {
                                editEventForm = new EditCalendarEventItem(actualEvents, this.eventlistBindingSource);
                                editActionForm = new EditCalendarActionItem(actualActions, actualEvents, facility_tracksBindingSource,
            groupsBindingSource, group_headersBindingSource);
                            }
                            break;
                        default:
                            editEventForm = null;
                            editActionForm = null;
                            break;
                    }

                    if (this.GenericEditEvent(editEventForm, actualEvents))
                    {
                        SaveChanges();
                        actualActions.MoveFirst();
                        //если есть записи
                        bool isNew = (actualActions.Current == null) ? true : false;

                //        if (this.EditCurrentAction(this.actionsBindingSource, eventsBindingSource, facility_tracksBindingSource,
                //groupsBindingSource, group_headersBindingSource, isNew))
                            if (this.GenericEditAction(editActionForm, this.actionsBindingSource, group_headersBindingSource, isNew))
                            SaveChanges();

                        PrepareSelected();
                        //восстановить положение скроллбара
                        if (saveRow != 0 && saveRow < dgv1.Rows.Count)
                            dgv1.FirstDisplayedScrollingRowIndex = saveRow;
                    }
                }
                else if (cellTag.Equals("new"))
                {
                    DateTime newEventDate = GetCurrentDate(colIndex, dt1.Value);
                    DateTime begin;
                    DateTime end;
                    string btime = String.Format("{0} {1}", currDate.ToShortDateString(), dgv1.Rows[rowIndex].HeaderCell.Value);
                    begin = Convert.ToDateTime(btime);
                    end = begin.AddMinutes(90);

                    Properties.Settings.Default.lastEditEventBeginTime = begin.ToShortTimeString();
                    Properties.Settings.Default.lastEditEventEndTime = end.ToShortTimeString();

                    //if (this.EditCurrentEvent(actualEvents, this.eventlistBindingSource, newEventDate, new DateTime(), true, false))
                    //выбираем кейсом eCategory и создаем IEditable;

                    IEditable editEventForm = null;
                    IEditable editActionForm = null;

                    switch (eCategory)
//.........这里部分代码省略.........
开发者ID:hprog,项目名称:exchange,代码行数:101,代码来源:Plans.cs

示例2: GetFormattedValue

        protected override object GetFormattedValue(
            object value,
            int rowIndex,
            ref DataGridViewCellStyle cellStyle,
            TypeConverter valueTypeConverter,
            TypeConverter formattedValueTypeConverter,
            DataGridViewDataErrorContexts context)
        {
            if (value == null)
                return null;
            int iValue;
            if (Int32.TryParse(value.ToString(), out iValue))
                if (iValue == CashedValue)
                    return CashedFormattedValue;

            var col = OwningColumn as DataGridViewDictionaryColumn;
            var CurrBS = col.DataSource as BindingSource;
            if (CurrBS == null)
                return null;
            var bs = new BindingSource()
                         {
                             DataSource = CurrBS.DataSource,
                             DataMember = CurrBS.DataMember,
                             Sort = CurrBS.Sort,
                             Filter = CurrBS.Filter
                         };
            var iPos = bs.Find(col.ValueMember, value);
            if (iPos<0)
                return null;
            bs.Position = iPos;
            var row = (bs.Current as DataRowView).Row;
            var sValue = String.IsNullOrEmpty(col.DescriptionMember)
                             ? String.Format(col.Format, row[col.DisplayMember])
                             : String.Format(col.Format, row[col.DisplayMember], row[col.DescriptionMember]);
            if (Int32.TryParse(value.ToString(), out iValue))
            {
                CashedValue = iValue;
                CashedFormattedValue = sValue;
            }
            return sValue;
        }
开发者ID:PeletonSoft,项目名称:Orders,代码行数:41,代码来源:DataGridViewDictionaryCell.cs

示例3: DeleteEvent

        private void DeleteEvent(int colIndex, int rowIndex, BindingSource actualEvents)
        {
            //запомнить положение скроллбара
            int saveRow = 0;
            if (dgv1.Rows.Count > 0)
                saveRow = dgv1.FirstDisplayedCell.RowIndex;

            int currEvent = 0;

            string cellTag = Convert.ToString(dgv1[colIndex, rowIndex].Tag);

            if (Int32.TryParse(cellTag, out currEvent))
            {
                if ((dgv1.collapseEvents.Keys.Contains(currEvent)) && (dgv1[colIndex, rowIndex].Style.BackColor == event_error_bg))
                {
                    string filter = String.Format("[{0}] IN ({1}, {2})", currEventField, currEvent, dgv1.collapseEvents[currEvent]);
                    CollapseSelect cs = new CollapseSelect(filter, eCategory);

                    if (cs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        currEvent = cs.ReturnEventID();
                    }
                    else
                        return;
                }
            }
            else
            {
                ulog.Message("Не удается определить мероприятие.", UserLogMessageLevel.Error);
                return;
            }

            actualEvents.Position = actualEvents.Find(currEventField , currEvent);

            if (ConfirmDeletion("Мероприятие"))
                try
                {
                    actualEvents.RemoveCurrent();
                    ulog.Message("Запись мероприятия удалена.");
                    SaveChanges();

                    PrepareSelected();
                    //восстановить положение скроллбара
                    if (saveRow != 0 && saveRow < dgv1.Rows.Count)
                        dgv1.FirstDisplayedScrollingRowIndex = saveRow;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
        }
开发者ID:hprog,项目名称:exchange,代码行数:51,代码来源:Plans.cs


注:本文中的System.Windows.Forms.BindingSource.Find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。