public static void BeginUpdateInvoke(this ListView widget) { if (widget == null) throw new ArgumentNullException("widget"); widget.Invoke((Action)delegate { widget.BeginUpdate(); }); }
public static void LoadItems(this ComboBox cmb, Object[] items) { cmb.BeginUpdate(); cmb.Items.Clear(); cmb.Items.AddRange(items); cmb.EndUpdate(); }
public static void LoadItems(this CheckedListBox listBox, Object[] items) { listBox.BeginUpdate(); listBox.Items.Clear(); listBox.Items.AddRange(items); listBox.EndUpdate(); }
public static void CheckAll(this CheckedListBox checkedListBox, bool check) { if (checkedListBox == null) { throw new ArgumentNullException("checkedListBox"); } checkedListBox.BeginUpdate(); for (int i = 0; i < checkedListBox.Items.Count; i++) { checkedListBox.SetItemChecked(i, check); } checkedListBox.EndUpdate(); }
public static void LoadShape(this C1VectorLayer vl, Stream stream, Stream dbfStream, bool centerAndZoom, ProcessShapeItem processShape) { Dictionary<C1VectorItemBase, C1ShapeAttributes> vects = ShapeReader.Read(stream, dbfStream); vl.BeginUpdate(); foreach (C1VectorItemBase vect in vects.Keys) { if (processShape != null) { processShape(vect, vects[vect]); } vl.Children.Add(vect); } vl.EndUpdate(); }
public static void LoadKML(this C1VectorLayer vl, Stream stream, bool centerAndZoom, ProcessVectorItem processVector) { using (StreamReader sr = new StreamReader(stream)) { string s = sr.ReadToEnd(); List<C1VectorItemBase> vects = KmlReader.Read(s); vl.BeginUpdate(); foreach (C1VectorItemBase vect in vects) { if (processVector != null) { if (!processVector(vect)) continue; } vl.Children.Add(vect); } vl.EndUpdate(); if (centerAndZoom) { Rect bnds = vects.GetBounds(); C1Maps maps = ((IMapLayer)vl).ParentMaps; if(maps != null) { maps.Center = new Point(bnds.Left + 0.5 * bnds.Width, bnds.Top + 0.5 * bnds.Height); double scale = Math.Max(bnds.Width / 360 * maps.ActualWidth, bnds.Height / 180 * maps.ActualHeight); ; double zoom = Math.Log(512 / scale, 2.0); maps.TargetZoom = maps.Zoom = zoom > 0 ? zoom : 0; } } sr.Close(); } }
/// <summary> /// Resizes the width of the columns. /// </summary> /// <param name="source">ListView object.</param> public static void AutoResizeColumns(this ListView source) { source.BeginUpdate(); try { foreach (ColumnHeader column in source.Columns) { column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); int columnContentWidth = column.Width; column.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); int headerWidth = column.Width; column.Width = Math.Max(columnContentWidth, headerWidth); } } finally { source.EndUpdate(); } }
public static void SetXHTMLText(this RichTextBox rtb, string xhtmlText) { rtb.Clear(); Stack<CHARFORMAT> scf = new Stack<CHARFORMAT>(); Stack<PARAFORMAT> spf = new Stack<PARAFORMAT>(); List<KeyValuePair<int, int>> links = new List<KeyValuePair<int, int>>(); CHARFORMAT cf = rtb.GetDefaultCharFormat(); // to apply character formatting PARAFORMAT pf = rtb.GetDefaultParaFormat(); // to apply paragraph formatting rtb.HideSelection = true; int oldMask = rtb.BeginUpdate(); int hyperlinkStart = -1; string hyperlink = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; try { using (XmlReader reader = XmlReader.Create(new StringReader(xhtmlText), settings)) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: switch (reader.Name.ToLower()) { case "b": cf.dwMask |= CFM.WEIGHT | CFM.BOLD; cf.dwEffects |= CFE.BOLD; cf.wWeight = FW.BOLD; break; case "i": cf.dwMask |= CFM.ITALIC; cf.dwEffects |= CFE.ITALIC; break; case "u": cf.dwMask |= CFM.UNDERLINE | CFM.UNDERLINETYPE; cf.dwEffects |= CFE.UNDERLINE; cf.bUnderlineType = CFU.UNDERLINE; break; case "s": cf.dwMask |= CFM.STRIKEOUT; cf.dwEffects |= CFE.STRIKEOUT; break; case "sup": cf.dwMask |= CFM.SUPERSCRIPT; cf.dwEffects |= CFE.SUPERSCRIPT; break; case "sub": cf.dwMask |= CFM.SUBSCRIPT; cf.dwEffects |= CFE.SUBSCRIPT; break; case "a": hyperlinkStart = rtb.TextLength; hyperlink = null; while (reader.MoveToNextAttribute()) { switch (reader.Name.ToLower()) { case "href": hyperlink = reader.Value; break; } } reader.MoveToElement(); break; case "p": spf.Push(pf); while (reader.MoveToNextAttribute()) { switch (reader.Name.ToLower()) { case "align": if (reader.Value == "left") { pf.dwMask |= PFM.ALIGNMENT; pf.wAlignment = PFA.LEFT; } else if (reader.Value == "right") { pf.dwMask |= PFM.ALIGNMENT; pf.wAlignment = PFA.RIGHT; } else if (reader.Value == "center") { pf.dwMask |= PFM.ALIGNMENT; pf.wAlignment = PFA.CENTER; } break; } } reader.MoveToElement(); break; case "li": spf.Push(pf); if (pf.wNumbering != PFN.BULLET) { pf.dwMask |= PFM.NUMBERING; pf.wNumbering = PFN.BULLET; } break; case "font": scf.Push(cf); string strFont = cf.szFaceName; int crFont = cf.crTextColor; int yHeight = cf.yHeight; while (reader.MoveToNextAttribute()) { switch (reader.Name.ToLower()) { case "face": cf.dwMask |= CFM.FACE; strFont = reader.Value; break; case "size": cf.dwMask |= CFM.SIZE; yHeight = int.Parse(reader.Value); yHeight *= (20 * 5); break; case "color": cf.dwMask |= CFM.COLOR; string text = reader.Value; if (text.StartsWith("#")) { string strCr = text.Substring(1); int nCr = Convert.ToInt32(strCr, 16); Color color = Color.FromArgb(nCr); crFont = GetCOLORREF(color); } else if (!int.TryParse(text, out crFont)) { Color color = Color.FromName(text); crFont = GetCOLORREF(color); } break; } } reader.MoveToElement(); cf.szFaceName = strFont; cf.crTextColor = crFont; cf.yHeight = yHeight; cf.dwEffects &= ~CFE.AUTOCOLOR; break; } break; case XmlNodeType.EndElement: switch (reader.Name) { case "b": cf.dwEffects &= ~CFE.BOLD; cf.wWeight = FW.NORMAL; break; case "i": cf.dwEffects &= ~CFE.ITALIC; break; case "u": cf.dwEffects &= ~CFE.UNDERLINE; break; case "s": cf.dwEffects &= ~CFE.STRIKEOUT; break; case "sup": cf.dwEffects &= ~CFE.SUPERSCRIPT; break; case "sub": cf.dwEffects &= ~CFE.SUBSCRIPT; break; case "a": int length = rtb.TextLength - hyperlinkStart; if (hyperlink != null) { rtb.Select(hyperlinkStart, length); if (hyperlink != rtb.SelectedText) { string rtfText = rtb.SelectedRtf; int idx = rtfText.LastIndexOf('}'); if (idx != -1) { string head = rtfText.Substring(0, idx); string tail = rtfText.Substring(idx); rtb.SelectedRtf = head + @"\v #" + hyperlink + @"\v0" + tail; length = rtb.TextLength - hyperlinkStart; } } // reposition to final rtb.Select(rtb.TextLength + 1, 0); } links.Add(new KeyValuePair<int, int>(hyperlinkStart, length)); hyperlinkStart = -1; break; case "p": pf = spf.Pop(); break; case "li": pf = spf.Pop(); break; case "font": cf = scf.Pop(); break; } break; case XmlNodeType.Text: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: string strData = reader.Value; bool bNewParagraph = (strData.IndexOf("\r\n", 0) >= 0) || (strData.IndexOf("\n", 0) >= 0); if (strData.Length > 0) { // now, add text to control int nStartCache = rtb.SelectionStart; rtb.SelectedText = strData; rtb.Select(nStartCache, strData.Length); // apply format rtb.SetParaFormat(pf); rtb.SetCharFormat(cf); } // reposition to final rtb.Select(rtb.TextLength + 1, 0); // new paragraph requires to reset alignment if (bNewParagraph) { pf.dwMask = PFM.ALIGNMENT | PFM.NUMBERING; pf.wAlignment = PFA.LEFT; pf.wNumbering = 0; } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: break; case XmlNodeType.Comment: break; default: break; } } } } catch (System.Xml.XmlException ex) { Debug.WriteLine(ex.Message); } rtb.HideSelection = false; // apply links style CHARFORMAT ncf = new CHARFORMAT(CFM.LINK, CFE.LINK); foreach (var pair in links) { rtb.Select(pair.Key, pair.Value); rtb.SetCharFormat(ncf); } // reposition to final rtb.Select(rtb.TextLength + 1, 0); rtb.EndUpdate(oldMask); }
public static void SetXHTMLText(this RichTextBox rtb, string xhtmlText) { List<KeyValuePair<int,int>> links = new List<KeyValuePair<int,int>>(); rtb.Clear(); rtb.HideSelection = true; int oldMask = rtb.BeginUpdate(); DoRTBUpdate(rtb, xhtmlText, links); rtb.HideSelection = false; rtb.EndUpdate(oldMask); }
static public void SyncWith(this SessionBase sessionToUpdate, SessionBase sessionToRead, Func<SessionBase, UInt64, Change, bool> doUpdate) { UInt64 currentVersion; UInt64 pageToReadVersion; bool conflictFound = false; using (var reader = sessionToRead.BeginRead()) { Changes changes = (Changes)sessionToRead.Open(5, 1, 1, false); if (changes != null) { using (var updater = sessionToUpdate.BeginUpdate()) { var dbs = sessionToUpdate.OpenAllDatabases(); ReplicaSync matchingReplicaSync = null; foreach (ReplicaSync sync in sessionToUpdate.AllObjects<ReplicaSync>()) { if (sync.SyncFromHost == sessionToRead.SystemHostName && sync.SyncFromPath == sessionToRead.SystemDirectory) { matchingReplicaSync = sync; break; } } if (changes.ChangeList.Count > 0) { foreach (TransactionChanges transactionChanges in changes.ChangeList) { if (matchingReplicaSync == null || matchingReplicaSync.TransactionNumber < transactionChanges.TransactionNumber) { foreach (Change change in transactionChanges.ChangeList) { Database dbToUpdate = sessionToUpdate.OpenDatabase(change.DatabaseId, false, false); Database dbToRead = sessionToRead.OpenDatabase(change.DatabaseId, false, false); string dbName = dbToRead != null ? dbToRead.Name : null; if (change.Deleted) { if (dbToUpdate == null) // does not exist continue; if (change.PageId == 0) // Database delete { currentVersion = dbToUpdate.Page.PageInfo.VersionNumber; if (currentVersion < change.Version) sessionToUpdate.DeleteDatabase(dbToUpdate); else { conflictFound = true; if (doUpdate(sessionToUpdate, currentVersion, change)) sessionToUpdate.DeleteDatabase(dbToUpdate); } } else { Page page = sessionToUpdate.OpenPage(dbToUpdate, change.PageId); if (page == null) // page does not exist continue; currentVersion = page.PageInfo.VersionNumber; if (currentVersion < change.Version) sessionToUpdate.DeletePage(dbToUpdate, page); else { conflictFound = true; if (doUpdate(sessionToUpdate, currentVersion, change)) sessionToUpdate.DeleteDatabase(dbToUpdate); } } } else { if (dbToUpdate == null) // does not exist dbToUpdate = sessionToUpdate.NewDatabase(change.DatabaseId, 0, dbName); if (change.PageId > 0) { Page pageToUpdate = sessionToUpdate.OpenPage(dbToUpdate, change.PageId); Page pageToRead = sessionToRead.OpenPage(dbToRead, change.PageId); if (pageToRead == null) // upcoming (not yet processed) changes must have deleted this page continue; currentVersion = pageToUpdate == null ? 0 : pageToUpdate.PageInfo.VersionNumber; pageToReadVersion = pageToRead.PageInfo.VersionNumber; if (currentVersion < pageToReadVersion || dbToUpdate.IsNew) sessionToUpdate.ReplacePage(dbToUpdate, pageToUpdate, pageToRead); else { conflictFound = true; if (doUpdate(sessionToUpdate, currentVersion, change)) sessionToUpdate.ReplacePage(dbToUpdate, pageToUpdate, pageToRead); } } } } } } UInt64 lastTransactionNumber = changes.ChangeList.Last().TransactionNumber; if (matchingReplicaSync != null) matchingReplicaSync.TransactionNumber = lastTransactionNumber; if (conflictFound) { sessionToUpdate.Verify(); } sessionToUpdate.Commit(); if (matchingReplicaSync == null) { sessionToUpdate.BeginUpdate(); // separate transaction or else gets confused with databases added by sync matchingReplicaSync = new ReplicaSync(sessionToRead, lastTransactionNumber); sessionToUpdate.Persist(matchingReplicaSync); sessionToUpdate.Commit(); } } } } } }
/// <summary> /// Переместить выбранный узел дерева и элемент соответствующего списка в заданную позицию /// </summary> public static void MoveSelectedNode(this TreeView treeView, int newIndex) { TreeNode selectedNode = treeView.SelectedNode; ITreeNode selectedObj = selectedNode == null ? null : selectedNode.Tag as ITreeNode; if (selectedObj != null) { try { treeView.BeginUpdate(); TreeNodeCollection nodes = treeView.GetChildNodes(selectedNode.Parent); IList list = selectedObj.Parent.Children; if (0 <= newIndex && newIndex < nodes.Count) { int index = selectedNode.Index; nodes.RemoveAt(index); nodes.Insert(newIndex, selectedNode); list.RemoveAt(index); list.Insert(newIndex, selectedObj); treeView.SelectedNode = selectedNode; } } finally { treeView.EndUpdate(); } } }
/// <summary> /// Переместить выбранный узел дерева и элемент соответствующего списка вверх по дереву /// </summary> public static void MoveUpSelectedNode(this TreeView treeView, MoveBehavior moveBehavior) { TreeNode selectedNode = treeView.SelectedNode; ITreeNode selectedObj = selectedNode == null ? null : selectedNode.Tag as ITreeNode; if (selectedObj != null) { try { treeView.BeginUpdate(); TreeNodeCollection nodes = treeView.GetChildNodes(selectedNode.Parent); IList list = selectedObj.Parent.Children; int index = selectedNode.Index; int newIndex = index - 1; if (newIndex >= 0) { nodes.RemoveAt(index); nodes.Insert(newIndex, selectedNode); list.RemoveAt(index); list.Insert(newIndex, selectedObj); treeView.SelectedNode = selectedNode; } else if (moveBehavior == MoveBehavior.ThroughSimilarParents) { TreeNode parentNode = selectedNode.Parent; TreeNode prevParentNode = parentNode == null ? null : parentNode.PrevNode; if (parentNode != null && prevParentNode != null && parentNode.Tag is ITreeNode && prevParentNode.Tag is ITreeNode && parentNode.Tag.GetType() == prevParentNode.Tag.GetType()) { // изменение родителя перемещаемого узла nodes.RemoveAt(index); prevParentNode.Nodes.Add(selectedNode); ITreeNode prevParentObj = (ITreeNode)prevParentNode.Tag; list.RemoveAt(index); prevParentObj.Children.Add(selectedObj); selectedObj.Parent = prevParentObj; treeView.SelectedNode = selectedNode; } } } finally { treeView.EndUpdate(); } } }
public static string GetPlaintText(this RichTextBox rtb) { //rtb.HideSelection = true; IntPtr oldMask = rtb.BeginUpdate(); int nStart = rtb.SelectionStart; int nEnd = rtb.SelectionLength; StringBuilder text = new StringBuilder(); try { //-------------------------------- // this is an inefficient method to get text format // but RichTextBox doesn't provide another method to // get something like an array of charformat and paraformat //-------------------------------- for (int i = 0; i < rtb.TextLength; i++) { // select one character rtb.Select(i, 1); text.Append(rtb.SelectedText); } } catch (Exception /*ex*/) { //MessageBox.Show(ex.Message); } finally { //-------------------------- // finish, restore rtb.SelectionStart = nStart; rtb.SelectionLength = nEnd; rtb.EndUpdate(oldMask); rtb.HideSelection = false; //-------------------------- } return text.ToString(); }
public static string GetXHTMLText(this RichTextBox rtb, bool bParaFormat) { StringBuilder strHTML = new StringBuilder(); rtb.HideSelection = true; IntPtr oldMask = rtb.BeginUpdate(); int nStart = rtb.SelectionStart; int nEnd = rtb.SelectionLength; try { // to store formatting List<KeyValuePair<int, string>> colFormat = new List<KeyValuePair<int, string>>(); string strT = ProcessTags(rtb, colFormat, bParaFormat); // apply format by replacing and inserting HTML tags // stored in the Format Array int nAcum = 0; for (int i = 0; i < colFormat.Count; i++) { var mfr = colFormat[i]; strHTML.Append(WebUtility.HtmlEncode(strT.Substring(nAcum, mfr.Key - nAcum)) + mfr.Value); nAcum = mfr.Key; } if (nAcum < strT.Length) strHTML.Append(strT.Substring(nAcum)); } catch (Exception /*ex*/) { //MessageBox.Show(ex.Message); } finally { // finish, restore rtb.SelectionStart = nStart; rtb.SelectionLength = nEnd; rtb.EndUpdate(oldMask); rtb.HideSelection = false; } return strHTML.ToString(); }
public static void SetXHTMLText(this RichTextBox rtb, string xhtmlText) { rtb.Clear(); Stack<CHARFORMAT> scf = new Stack<CHARFORMAT>(); Stack<PARAFORMAT> spf = new Stack<PARAFORMAT>(); List<KeyValuePair<int, int>> links = new List<KeyValuePair<int, int>>(); CHARFORMAT cf = rtb.GetDefaultCharFormat(); // to apply character formatting PARAFORMAT pf = rtb.GetDefaultParaFormat(); // to apply paragraph formatting rtb.HideSelection = true; int oldMask = rtb.BeginUpdate(); int hyperlinkStart = -1; string hyperlink = null; XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; try { using (XmlReader reader = XmlReader.Create(new StringReader(xhtmlText), settings)) { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: ProcessXmlElement(rtb, scf, spf, ref cf, ref pf, ref hyperlinkStart, ref hyperlink, reader); break; case XmlNodeType.EndElement: ProcessXmlEndElement(rtb, scf, spf, links, ref cf, ref pf, ref hyperlinkStart, hyperlink, reader); break; case XmlNodeType.Text: case XmlNodeType.Whitespace: case XmlNodeType.SignificantWhitespace: string strData = reader.Value; bool bNewParagraph = ProcessSignificantWhitespace(rtb, ref cf, ref pf, strData); // new paragraph requires to reset alignment if (bNewParagraph) { pf.dwMask = PFM.ALIGNMENT | PFM.NUMBERING; pf.wAlignment = PFA.LEFT; pf.wNumbering = 0; } break; case XmlNodeType.XmlDeclaration: case XmlNodeType.ProcessingInstruction: break; case XmlNodeType.Comment: break; default: break; } } } } catch (System.Xml.XmlException ex) { Debug.WriteLine(ex.Message); } rtb.HideSelection = false; // apply links style CHARFORMAT ncf = new CHARFORMAT(CFM.LINK, CFE.LINK); foreach (var pair in links) { rtb.Select(pair.Key, pair.Value); rtb.SetCharFormat(ncf); } // reposition to final rtb.Select(rtb.TextLength + 1, 0); rtb.EndUpdate(oldMask); }
/// <summary> /// Обновить список строк, загрузив данные из файла /// </summary> public static void RefreshListBox(this ListBox listBox, string fileName, bool fullLoad, ref DateTime fileAge) { Monitor.Enter(listBox); try { if (File.Exists(fileName)) { DateTime newFileAge = GetLastWriteTime(fileName); if (fileAge != newFileAge) { // загрузка строк из файла List<string> stringList = LoadStrings(fileName, fullLoad); int newLineCnt = stringList.Count; // проверка для исключения отображения данных, считыванных в момент записи файла if (newLineCnt > 0 || (DateTime.Now - newFileAge).TotalMilliseconds > 50) { fileAge = newFileAge; // вывод данных в список int oldLineCnt = listBox.Items.Count; int selectedIndex = listBox.SelectedIndex; int topIndex = listBox.TopIndex; listBox.BeginUpdate(); for (int i = 0; i < newLineCnt; i++) { if (i < oldLineCnt) listBox.Items[i] = stringList[i]; else listBox.Items.Add(stringList[i]); } for (int i = newLineCnt; i < oldLineCnt; i++) listBox.Items.RemoveAt(newLineCnt); // установка позиции прокрутки списка if (listBox.SelectionMode == SelectionMode.One && newLineCnt > 0) { if (selectedIndex < 0 && !fullLoad) listBox.SelectedIndex = newLineCnt - 1; // прокрутка в конец списка else listBox.TopIndex = topIndex; } listBox.EndUpdate(); } } } else { if (listBox.Items.Count == 1) { listBox.Items[0] = CommonPhrases.NoData; } else { listBox.Items.Clear(); listBox.Items.Add(CommonPhrases.NoData); } fileAge = DateTime.MinValue; } } catch (Exception ex) { if (listBox.Items.Count == 2) { listBox.Items[0] = CommonPhrases.ErrorWithColon; listBox.Items[1] = ex.Message; } else { listBox.Items.Clear(); listBox.Items.Add(CommonPhrases.ErrorWithColon); listBox.Items.Add(ex.Message); } fileAge = DateTime.MinValue; } finally { Monitor.Exit(listBox); } }
/// <summary>Suspends drawing, updates, then redraws a <see cref="TreeView"/>.</summary> public static void Update(this TreeView tree, Action update) { tree.BeginUpdate(); update(); tree.EndUpdate(); }
/// <summary> /// FlexGrid를 트리 형식으로 구성한다. /// e.g.) felxGrid.x_TreeSetting(datasource, 0, 1, false, false, false); /// </summary> /// <param name="flexGrid"></param> /// <param name="dt">바인딩을 위한 데이터 소스(데이터 소스는 표현될 트리와 동일한 형식으로 구성되어 있어야 함. 트리 노드에 나타날 컬럼과 현재 노드의 레벨이 반드시 지정되어 있어야 함</param> /// <param name="treeCol">트리노드에 나타날 컬럼의 인덱스</param> /// <param name="levelCol">노드의 레벨 정보를 가지고 있는 컬럼의 인덱스</param> /// <param name="expandLevel">처음 로드시 확장될 레벨 값 (e.g. 0으로 지정된 경우 최상위 노드만 보여지고 나머지 레벨은 접혀있음)</param> /// <param name="isVertical">트리를 수직으로 표현할 지를 결정. 즉 노드의 수평 라인을 제거</param> /// <param name="isHeader">헤더 표시 여부</param> /// <param name="isTopLevel">최상위 노드 표시 여부</param> /// <remarks> /// ------------------------------------- /// | treeCol | level | etc1 | etc2 | /// ------------------------------------- /// | 대분류 Data | 0 | etc1 | etc2 | /// ------------------------------------- /// | 소분류 Data | 1 | etc1 | etc2 | /// ------------------------------------- /// | 중분류 Data | 2 | etc1 | etc2 | /// ------------------------------------- /// /// e.g.) flexGrid.x_TreeSetting(datasource, 0, 1, false, false, false); /// </remarks> public static void x_TreeSetting(this C1FlexGrid flexGrid, System.Data.DataTable dt, int treeCol, int levelCol, int expandLevel, bool isVertical, bool isHeader, bool isTopLevel) { int START_ROW = 0; int END_ROW = 0; treeCol += 10; levelCol += 10; if (dt.Rows.Count == 0) return; flexGrid.BeginUpdate(); //Tree 초기화(ROW선 없앰) if (isVertical) { C1.Win.C1FlexGrid.CellStyle cs = flexGrid.Styles.Normal; cs.Border.Direction = C1.Win.C1FlexGrid.BorderDirEnum.Vertical; } flexGrid.Tree.Column = treeCol; flexGrid.Tree.Style = TreeStyleFlags.Simple; flexGrid.AllowMerging = AllowMergingEnum.Nodes; flexGrid.Tree.Indent = 1; //최상위레벨 존재하는 경우 if (isTopLevel) { flexGrid.Rows.Count = dt.Rows.Count + flexGrid.Rows.Fixed + 1; START_ROW = 1; END_ROW = dt.Rows.Count + 1; flexGrid.SetData(flexGrid.Rows.Fixed, levelCol, 0); flexGrid.SetData(flexGrid.Rows.Fixed, treeCol, "[전체]"); flexGrid.Rows[flexGrid.Rows.Fixed].IsNode = true; flexGrid.Rows[flexGrid.Rows.Fixed].Node.Level = 0; } else { flexGrid.Rows.Count = dt.Rows.Count + flexGrid.Rows.Fixed; START_ROW = 0; END_ROW = dt.Rows.Count; } for (int i = START_ROW; i < END_ROW; i++) { for (int j = 0; j < dt.Columns.Count; j++) { if (flexGrid.Cols.Count == 0) { flexGrid.SetData(i + flexGrid.Rows.Fixed, j, dt.Rows[i - START_ROW][j]); } else if (flexGrid.Cols.Count > 0 && FlexGridFindCol(flexGrid, dt.Columns[j].ColumnName) > -1) { flexGrid.SetData(i + flexGrid.Rows.Fixed, dt.Columns[j].ColumnName, dt.Rows[i - START_ROW][j]); } else { continue; } } // 로우에 노드를 만든다 flexGrid.Rows[i + flexGrid.Rows.Fixed].IsNode = true; // 노드의 레벨을 설정(Level) flexGrid.Rows[i + flexGrid.Rows.Fixed].Node.Level = ToInt(flexGrid.Rows[i + flexGrid.Rows.Fixed][levelCol]); } //노드확장 수준 결정 if (isTopLevel) flexGrid.Rows[flexGrid.Rows.Fixed].Node.Collapsed = true; for (int i = START_ROW; i < END_ROW; i++) { //확장레벨보다 하위레벨이면 Collapse처리 if (ToInt(flexGrid.Rows[i + flexGrid.Rows.Fixed][levelCol]) >= expandLevel) flexGrid.Rows[i + flexGrid.Rows.Fixed].Node.Collapsed = true; else flexGrid.Rows[i + flexGrid.Rows.Fixed].Node.Collapsed = false; } //헤더표시 여부 if (!isHeader) { for (int i = 0; i < flexGrid.Rows.Fixed; i++) { flexGrid.Rows.Remove(i); } flexGrid.Rows.Fixed = 0; } flexGrid.EndUpdate(); flexGrid.Refresh(); }
public static void SelectDeselectAll( this MSWinForms.ListView lv, bool bSelected = true) { lv.BeginUpdate(); bool bChk = lv.CheckBoxes; foreach (MSWinForms.ListViewItem lvi in lv.Items) { if (bChk) lvi.Checked = bSelected; else lvi.Selected = bSelected; } lv.EndUpdate(); }