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


C# DataObject.GetData方法代码示例

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


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

示例1: dg_Student_Drop

        private void dg_Student_Drop(object sender, DragEventArgs e)
        {
            DataGrid dg = sender as DataGrid;
            if (dg.SelectedItems.Count == 0)
            {
                ModernDialog.ShowMessage("没有选择要分班的记录,请先框选需要指定班级的记录", "消息", MessageBoxButton.OK);
                return;
            }
            // 注册Drop事件用来接收数据。
            IDataObject data = new DataObject();
            data = e.Data;
            object obj = data.GetData(typeof(BanJiSummaryModel));

            if (obj != null)
            {
                bool isShowDialog = true;//是否显示对话框
                bool isOverRide = true;//是否替换已有班级信息
                foreach (DataRowView item in dg.SelectedItems)
                {
                    if (!string.IsNullOrEmpty(item.Row["班级编号"].ToString()))
                    {
                        if (isShowDialog)
                        {
                            MessageBoxResult result = ModernDialog.ShowMessage("所选记录中已存在班级信息,是否替换班级信息?", "消息",
                                MessageBoxButton.YesNoCancel);
                            if (result == MessageBoxResult.Cancel) return;
                            if (result == MessageBoxResult.Yes)
                            {
                                isShowDialog = false;
                                isOverRide = true;
                            }
                            if (result == MessageBoxResult.No)
                            {
                                isShowDialog =isOverRide= false;
                            }
                        }
                        //如果覆盖班级信息 则修改内容
                        if (isOverRide)
                        {
                            item.Row["班级编号"] = (obj as BanJiSummaryModel).Bjbh;
                            item.Row["班级名称"] = (obj as BanJiSummaryModel).Bjmc;
                            item.Row["是否修改"] = true;
                        }
                    }
                    else
                    {
                        item.Row["班级编号"] = (obj as BanJiSummaryModel).Bjbh;
                        item.Row["班级名称"] = (obj as BanJiSummaryModel).Bjmc;
                        item.Row["是否修改"] = true;
                    }
                }
            }
        }
开发者ID:yangdaichun,项目名称:ZHXY.ZSXT,代码行数:53,代码来源:StudentFenBanView.xaml.cs

示例2: Defaults

		public void Defaults ()
		{
			DataObject dobj = new DataObject ();

			Assert.Throws<SecurityException> (() => dobj.GetFormats (), "GetFormats ()");
			Assert.Throws<SecurityException> (() => dobj.GetFormats (true), "GetFormats (true)");
			Assert.Throws<SecurityException> (() => dobj.GetFormats (false), "GetFormats (false)");

			Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop), "GetData (string)");
			Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop, true), "GetData (string,true)");
			Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop, false), "GetData (string,false)");
			Assert.Throws<SecurityException> (() => dobj.GetData (typeof(string)), "GetData (Type)");

			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop), "GetDataPresent (string)");
			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop, true), "GetDataPresent (string,true)");
			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop, false), "GetDataPresent (string,false)");
			Assert.Throws<SecurityException> (() => dobj.GetDataPresent (typeof (string)), "GetDataPresent (Type)");

			Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop), "SetData (string)");
			Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop, true), "SetData (string,true)");
			Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop, false), "SetData (string,false)");
			Assert.Throws<SecurityException> (() => dobj.SetData (typeof (string)), "SetData (Type)");
		}
开发者ID:dfr0,项目名称:moon,代码行数:23,代码来源:DataObjectTest.cs

示例3: cvs1Drop

 private void cvs1Drop(object sender, DragEventArgs e) {
     IDataObject data = new DataObject();
     data = e.Data;
     if (data.GetDataPresent(typeof(Rectangle))) {
         Rectangle rect = new Rectangle();
         rect = data.GetData(typeof(Rectangle)) as Rectangle;
         //canvas2.Children.Remove(rect);
         //canvas2.Children.Add(rect);
         string rectXaml = XamlWriter.Save(rect);
         StringReader stringReader = new StringReader(rectXaml);
         XmlReader xmlReader = XmlReader.Create(stringReader);
         UIElement clonedChild = (UIElement)XamlReader.Load(xmlReader);
         canvas1.Children.Add(clonedChild);
     }
 }
开发者ID:ychost,项目名称:uest-pcs,代码行数:15,代码来源:MainWindow.xaml.cs

示例4: TextSelectionToDataObject

        private void TextSelectionToDataObject(object sender, RoutedEventArgs e)
        {
            // Create a new data object using one of the overloaded constructors.  This particular
            // overload accepts a string specifying the data format (provided by the DataFormats class),
            // and an Object (in this case a string) that represents the data to be stored in the data object.
            var dataObject = new DataObject(DataFormats.Text, sourceTextBox.SelectedText);

            dataObjectInfoTextBox.Clear();

            // Get and display the native data formats (filtering out auto-convertable data formats).
            dataObjectInfoTextBox.Text = "\nNative data formats present:\n";
            foreach (var format in dataObject.GetFormats(false /*autoconvert*/))
                dataObjectInfoTextBox.Text += format + "\n";

            // Display the data in the data object.
            dataObjectInfoTextBox.Text += "\nData contents:\n";
            dataObjectInfoTextBox.Text += dataObject.GetData(DataFormats.Text, false /*autoconvert*/).ToString();
        }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:18,代码来源:MainWindow.cs

示例5:

        void IDragSourceAdvisor.FinishDrag(DataObject draggedElt, DragDropEffects finalEffects, bool DropOk)
        {
            if (this.Mode == DragAndDropSourceMode.ReadOnly)
                return;

            if (DropOk == false)
                return;

            IList l = _ListBox.ItemsSource as IList;
            if (l == null)
                return;

            object oindex = draggedElt.GetData("OriginalSourceIndex");
            if (oindex != null)
            {
                l.RemoveAt((int)oindex);
                return;
            }

            List<int> indexes = draggedElt.GetData("OriginalSourceIndexes") as List<int>;
            if (indexes == null)
                return;

            indexes.OrderByDescending(i => i).Apply(ind => l.RemoveAt(ind));
        }
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:25,代码来源:ListDragAndDropSource.cs

示例6: TryGetData

 private static object TryGetData(DataObject dataObject, string dataFormat)
 {
     try
     {
         return dataObject.GetData(dataFormat);
     }
     catch (OutOfMemoryException)
     {
         Trace.TraceError("OutOfMemoryException thrown from DataObject.");
     }
     return null;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:12,代码来源:CutCopyPasteHelper.cs


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