-
کمک در مورد treeviwe
سلام
اطلاعاتم رو ارسال میکنم به sqlServer
توی sql یه جدول دارم که کالاها توش ذخیره میشن (ستونها : id -child -name -level -parent- description)
توی همون جدول هم Parent و child رو تعییم میکنم
حالا میخوام توی treeviwe نمایش بدم
کد زیر رو نوشتم ولی فقط نامها رو میاره
لطفا کمک بفرمایید.
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
TreeNode name = new TreeNode(reader["_proName"].ToString().Trim());
TV1.Nodes.Add(name);
}
-
نقل قول: کمک در مورد treeviwe
خب دوست عزیز شما کدی که نوشتید برای نام هاست و اون ها رو به TV1 اضافه میکنید.
خط 9 کدتون، رو به این کد تغییر بدین:
TV1.Nodes[reader["_proParrent"].ToString().Trim()].Nodes.Add(name);
در ضمن _proParrent رو به نام ستونی که اسم والد هست تغییر بدین (اگه همین نیست).
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
خب دوست عزیز شما کدی که نوشتید برای نام هاست و اون ها رو به TV1 اضافه میکنید.
خط 9 کدتون، رو به این کد تغییر بدین:
TV1.Nodes[reader["_proParrent"].ToString().Trim()].Nodes.Add(name);
در ضمن _proParrent رو به نام ستونی که اسم والد هست تغییر بدین (اگه همین نیست).
ممنونم که وقت میذارید
لطفا بیخیال کدهای من بشید و یه نمونه کد اگر ممکنه بهم بدید تا بتونم جدولم رو توی treeviwe بریزم
من از sqlserver استفاده میکنم و ستونهای جدولم هم اسمهاشون به ترتیب زیره:
_proid
_proKey
_proParent
_proLevel
_proName
_proDescription
ممنون
واقعا گیر کزدم
-
نقل قول: کمک در مورد treeviwe
من که گفتم، کل کدتون که این جا گذاشتین رو به این کد تغییر بدین:
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
TreeNode name = new TreeNode(reader["_proName"].ToString().Trim());
TV1.Nodes[reader["_proParent"].ToString().Trim()].Nodes.Add(name);
}
-
1 ضمیمه
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
من که گفتم، کل کدتون که این جا گذاشتین رو به این کد تغییر بدین:
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
TreeNode name = new TreeNode(reader["_proName"].ToString().Trim());
TV1.Nodes[reader["_proParent"].ToString().Trim()].Nodes.Add(name);
}
بازم ایراد میگیره
ضمیمه 150994
-
نقل قول: کمک در مورد treeviwe
اینجوری که خطا میگه احتمالا منظورش اینه که نام والد که در ستون proParent_ نوشتید با هیچ آیتمی در treeView همخوانی نداره.
به نظرم چند سطر جدول رو بنویسید اینجا که بفهمیم مشکل از کجاست.
و محتمل ترین مشکل اینه که شما برای والد ریشه به مشکل بر خوردین، منظورم اینه که برای اون هایی که والد ندارن در ستون proParent چی نوشتین؟
اگر خالی هست، این کد کمک میکنه:
if (reader["_proParent"].ToString().Trim() == "") TV1.Nodes.Add(name);
else
TV1.Nodes[reader["_proParent"].ToString().Trim()].Nodes.Add(name);
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
اینجوری که خطا میگه احتمالا منظورش اینه که نام والد که در ستون proParent_ نوشتید با هیچ آیتمی در treeView همخوانی نداره.
به نظرم چند سطر جدول رو بنویسید اینجا که بفهمیم مشکل از کجاست.
و محتمل ترین مشکل اینه که شما برای والد ریشه به مشکل بر خوردین، منظورم اینه که برای اون هایی که والد ندارن در ستون proParent چی نوشتین؟
اگر خالی هست، این کد کمک میکنه:
if (reader["_proParent"].ToString().Trim() == "") TV1.Nodes.Add(name);
else
TV1.Nodes[reader["_proParent"].ToString().Trim()].Nodes.Add(name);
ممنونم از وقت گذاشتن تون
برای مقدار والد در جدول چیزی ندارم و مقدار NULL هست
-
1 ضمیمه
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
اینجوری که خطا میگه احتمالا منظورش اینه که نام والد که در ستون proParent_ نوشتید با هیچ آیتمی در treeView همخوانی نداره.
به نظرم چند سطر جدول رو بنویسید اینجا که بفهمیم مشکل از کجاست.
و محتمل ترین مشکل اینه که شما برای والد ریشه به مشکل بر خوردین، منظورم اینه که برای اون هایی که والد ندارن در ستون proParent چی نوشتین؟
اگر خالی هست، این کد کمک میکنه:
if (reader["_proParent"].ToString().Trim() == "") TV1.Nodes.Add(name);
else
TV1.Nodes[reader["_proParent"].ToString().Trim()].Nodes.Add(name);
این هم بانکsqlضمیمه 150995
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
آقا شما که زحمت کشیدید لطفا با توجه به جدول یه نمونه کد بهم بدید که توی treeviwe نمایش بده
خدا خیرت بده
خیلی گیر کردم
توضیح : ردیف 8 و 9 جدول زیر مجموعه ردیف 1 هستند(در واقع فرزند هستند)
-
نقل قول: کمک در مورد treeviwe
من که دقیق نمیدونم چون الان امکانات هم ندارم فعلا نمیتونم عملی کار کنم ولی شما ببینید این کار میکنه؟
if (reader["_proParent"] == null) TV1.Nodes.Add(name);
else
TV1.Nodes[int(reader["_proParent"].ToString())].Nodes.Add(name);
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
من که دقیق نمیدونم چون الان امکانات هم ندارم فعلا نمیتونم عملی کار کنم ولی شما ببینید این کار میکنه؟
if (reader["_proParent"] == null) TV1.Nodes.Add(name);
else
TV1.Nodes[int(reader["_proParent"].ToString())].Nodes.Add(name);
متاسفانه همون خطا رو میده
-
نقل قول: کمک در مورد treeviwe
دیگه من واقعا نمیدونم شما یک بریک پوینت بزنید اون ستون رو چک کنید.
هر چی که هست چون مقدار Null هست این خطا رو میده.
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
دیگه من واقعا نمیدونم شما یک بریک پوینت بزنید اون ستون رو چک کنید.
هر چی که هست چون مقدار Null هست این خطا رو میده.
بهر حال ممنون که زمان گذاشتید:تشویق::تشویق:
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
ASHKANLAEI
دیگه من واقعا نمیدونم شما یک بریک پوینت بزنید اون ستون رو چک کنید.
هر چی که هست چون مقدار Null هست این خطا رو میده.
ستون parent رو هم از حالت NULL بیرون آوردم . بهش مقدار دادم ولی بازم همون خطا رو میده
کلا بجای ستون Parent هر ستونی رو میذارم تو کدی که هست بازم همون خطا رو میگیره.
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
سلام
اطلاعاتم رو ارسال میکنم به sqlServer
توی sql یه جدول دارم که کالاها توش ذخیره میشن (ستونها : id -child -name -level -parent- description)
توی همون جدول هم Parent و child رو تعییم میکنم
حالا میخوام توی treeviwe نمایش بدم
کد زیر رو نوشتم ولی فقط نامها رو میاره
لطفا کمک بفرمایید.
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
TreeNode name = new TreeNode(reader["_proName"].ToString().Trim());
TV1.Nodes.Add(name);
}
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
var reader = cmd.ExecuteReader();
var childItems = new List<KeyValuePair<TreeNode, string>>();
while (reader.Read())
{
var node = new TreeNode(reader["_proName"].ToString().Trim());
node.Name = reader["_proid"].ToString();
if (reader["_proParent"] == DBNull.Value)
{
TV1.Nodes.Add(node);
}
else
{
childItems.Add(new KeyValuePair<TreeNode, string>(node, reader["_proParent"].ToString()));
}
}
foreach (var item in childItems)
{
if (TV1.Nodes.ContainsKey(item.Value))
{
TV1.Nodes[item.Value].Nodes.Add(item.Key);
}
}
_cn.Close();
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
var reader = cmd.ExecuteReader();
var childItems = new List<KeyValuePair<TreeNode, string>>();
while (reader.Read())
{
var node = new TreeNode(reader["_proName"].ToString().Trim());
node.Name = reader["_proid"].ToString();
if (reader["_proParent"] == DBNull.Value)
{
TV1.Nodes.Add(node);
}
else
{
childItems.Add(new KeyValuePair<TreeNode, string>(node, reader["_proParent"].ToString()));
}
}
foreach (var item in childItems)
{
if (TV1.Nodes.ContainsKey(item.Value))
{
TV1.Nodes[item.Value].Nodes.Add(item.Key);
}
}
_cn.Close();
داداش واقعا خدا خیرت بده
احسنت
دستتون در نکنه
:تشویق::تشویق::تشویق::تشویق:: شویق::تشویق::تشویق::تشویق::ت ویق::تشویق:
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
var reader = cmd.ExecuteReader();
var childItems = new List<KeyValuePair<TreeNode, string>>();
while (reader.Read())
{
var node = new TreeNode(reader["_proName"].ToString().Trim());
node.Name = reader["_proid"].ToString();
if (reader["_proParent"] == DBNull.Value)
{
TV1.Nodes.Add(node);
}
else
{
childItems.Add(new KeyValuePair<TreeNode, string>(node, reader["_proParent"].ToString()));
}
}
foreach (var item in childItems)
{
if (TV1.Nodes.ContainsKey(item.Value))
{
TV1.Nodes[item.Value].Nodes.Add(item.Key);
}
}
_cn.Close();
فقط یه نکته داداش
وقتی زیر زیر مجموعه جدید برای فرزند تعریف میکنم
توی treeview نمیاره
یعنی فقط پدر و فرزند رو نشون میده و نوه رو نشون نمیده
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
فقط یه نکته داداش
وقتی زیر زیر مجموعه جدید برای فرزند تعریف میکنم
توی treeview نمیاره
یعنی فقط پدر و فرزند رو نشون میده و نوه رو نشون نمیده
نمیدونستم در جدول تون نوه و نتیجه هم دارین :
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
var reader = cmd.ExecuteReader();
var childItems = new List<KeyValuePair<TreeNode, string>>();
while (reader.Read())
{
var node = new TreeNode(reader["_proName"].ToString().Trim());
node.Name = reader["_proid"].ToString();
if (reader["_proParent"] == DBNull.Value)
{
TV1.Nodes.Add(node);
}
else
{
childItems.Add(new KeyValuePair<TreeNode, string>(node, reader["_proParent"].ToString()));
}
}
bool parentFound;
do
{
parentFound = false;
for (var i = 0; i < childItems.Count; i++)
{
var parents = TV1.Nodes.Find(childItems[i].Value, true);
if (parents.Length > 0)
{
parents[0].Nodes.Add(childItems[i].Key);
childItems.RemoveAt(i);
parentFound = true;
i--;
}
}
} while (parentFound);
_cn.Close();
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
نمیدونستم در جدول تون نوه و نتیجه هم دارین :
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
var reader = cmd.ExecuteReader();
var childItems = new List<KeyValuePair<TreeNode, string>>();
while (reader.Read())
{
var node = new TreeNode(reader["_proName"].ToString().Trim());
node.Name = reader["_proid"].ToString();
if (reader["_proParent"] == DBNull.Value)
{
TV1.Nodes.Add(node);
}
else
{
childItems.Add(new KeyValuePair<TreeNode, string>(node, reader["_proParent"].ToString()));
}
}
bool parentFound;
do
{
parentFound = false;
for (var i = 0; i < childItems.Count; i++)
{
var parents = TV1.Nodes.Find(childItems[i].Value, true);
if (parents.Length > 0)
{
parents[0].Nodes.Add(childItems[i].Key);
childItems.RemoveAt(i);
parentFound = true;
i--;
}
}
} while (parentFound);
_cn.Close();
آقا عالی بود
خدا خیرت بده:تشویق::تشویق::تشویق::تشو ق::تشویق::تشویق::تشویق:
آره بابا اینا یه طایفه هستن واسه خودشون کلی هم دور هم شادن:لبخند:
-
نقل قول: کمک در مورد treeviwe
سلام دوستان
برای اینکه تاپیک جدیدی ایجاد نکنم همینجا مشکل رو مطرح میکنم
این تصویر رو ببینید :
http://s7.picofile.com/file/83792950..._23_021128.jpg http://s7.picofile.com/file/8379295292/00.jpg
وقتی اومدم برای nod ها فونت بولد را تعریف میکنم همانطور که ملاحظه میکنید آخر حروف کلمات ناقص نمایش داده میشوند!! به نظرتون مشکل از کجاست!
Font boldFont = new Font("Arial", 8, FontStyle.Bold);
for (int i = 0; i < treeView_SourceCodes.Nodes.Count; i++)
{
treeView_SourceCodes.Nodes[i].NodeFont = boldFont;
}
-
1 ضمیمه
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
samiasoft
سلام دوستان
برای اینکه تاپیک جدیدی ایجاد نکنم همینجا مشکل رو مطرح میکنم
این تصویر رو ببینید :
http://s7.picofile.com/file/83792950..._23_021128.jpg http://s7.picofile.com/file/8379295292/00.jpg
وقتی اومدم برای nod ها فونت بولد را تعریف میکنم همانطور که ملاحظه میکنید آخر حروف کلمات ناقص نمایش داده میشوند!! به نظرتون مشکل از کجاست!
Font boldFont = new Font("Arial", 8, FontStyle.Bold);
for (int i = 0; i < treeView_SourceCodes.Nodes.Count; i++)
{
treeView_SourceCodes.Nodes[i].NodeFont = boldFont;
}
کار شما هیچ ایرادی نداره، ایراد از کدی است که طراح یا طراحان کنترل TreeView زحمت نوشتنش رو کشیدن. وقتی قراره یک Node نمایش داده بشه اول باید ابعاد طولی و عرضی متن بدست بیاد تا ببینن موقع رسم چه کادری رو اشغال میکنه و بعد کادرش رو بکشن و بعد متن رو داخلش رسم کنن. برای محاسبه ابعاد متن هم از TextRenderer.MeasureText استفاده کردن. تا اینجاش مشکلی نیست، ولی ایراد در اینه که بجای treeNode.Font که فرضا شما Bold اش کردین و متن بزرگتری داره محاسبه رو با treeNode.TreeView.Font رو انجام دادن که فونت پیشفرض گره های TreeView است و اندازه کوچکتری داشته. نتیجه این میشه که ابعادی که محاسبه می کنند برای اون متن Bold شده زیاده کوچیکه و متن داخلش کامل جا نمیشه. این تقصیر شما نیست، اشتباه کسی است که کد روتین رسم رو نوشته.
ضمیمه 151003
دو تا راه حل کلی وجود داره، راه حل اول اینه که بیایید عمدا فونت پیشفرض کل TreeView رو Bold کنید (treeView1.Font) و خودتون در گره هایی که باید Bold نباشن فونت Bold نشده قرار بدید.
اینطوری محاسبه بر اساس فونت Bold شده انجام میشه و متن چه Bold باشه و چه نباشه در کادر محاسبه شده جا میشه.
راه حل دوم اینه که treeView1.DrawMode رو TreeViewDrawMode.OwnerDrawAll قرار بدید و کل روتین TreeView1_DrawNode که رسم یک گره ئه دستی و با کد درست بنویسید.
شبیه این کار رو میشه با وراثت از کلاس TreeView هم انجام داد تا نتیجه یک کلاس جدید باشه ولی اساسش همونه بازنویسی روتین برای DrawNode ئه.
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
دو تا راه حل کلی وجود داره، راه حل اول اینه که بیایید عمدا فونت پیشفرض کل TreeView رو Bold کنید (treeView1.Font) و خودتون در گره هایی که باید Bold نباشن فونت Bold نشده قرار بدید.
اینطوری محاسبه بر اساس فونت Bold شده انجام میشه و متن چه Bold باشه و چه نباشه در کادر محاسبه شده جا میشه.
راه حل دوم اینه که treeView1.DrawMode رو TreeViewDrawMode.OwnerDrawAll قرار بدید و کل روتین TreeView1_DrawNode که رسم یک گره ئه دستی و با کد درست بنویسید.
شبیه این کار رو میشه با وراثت از کلاس TreeView هم انجام داد تا نتیجه یک کلاس جدید باشه ولی اساسش همونه بازنویسی روتین برای DrawNode ئه.
ممنونم بابت این راهنمایی و توضیحات مفیدتون
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
نمیدونستم در جدول تون نوه و نتیجه هم دارین :
SqlConnection _cn = new SqlConnection(DBConnectioin.conStr);
SqlCommand cmd = new SqlCommand("SELECT * FROM _pro ", _cn);
_cn.Open();
var reader = cmd.ExecuteReader();
var childItems = new List<KeyValuePair<TreeNode, string>>();
while (reader.Read())
{
var node = new TreeNode(reader["_proName"].ToString().Trim());
node.Name = reader["_proid"].ToString();
if (reader["_proParent"] == DBNull.Value)
{
TV1.Nodes.Add(node);
}
else
{
childItems.Add(new KeyValuePair<TreeNode, string>(node, reader["_proParent"].ToString()));
}
}
bool parentFound;
do
{
parentFound = false;
for (var i = 0; i < childItems.Count; i++)
{
var parents = TV1.Nodes.Find(childItems[i].Value, true);
if (parents.Length > 0)
{
parents[0].Nodes.Add(childItems[i].Key);
childItems.RemoveAt(i);
parentFound = true;
i--;
}
}
} while (parentFound);
_cn.Close();
سلام بر دوست عزیز
آقا به یه مشکل خوردم
ببینید من یه فرم دارم حاوی دیتا گرید و تری ویو
وقتی یک رکورد اضافه میکنم دیتاگرید آپدیت میشه
ولی از هر متدی استفاده میکنم تری ویو آپدیت نمیشه
هم از refresh هم از Update ولی نمیشه
ممنون
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
سلام بر دوست عزیز
آقا به یه مشکل خوردم
ببینید من یه فرم دارم حاوی دیتا گرید و تری ویو
وقتی یک رکورد اضافه میکنم دیتاگرید آپدیت میشه
ولی از هر متدی استفاده میکنم تری ویو آپدیت نمیشه
هم از refresh هم از Update ولی نمیشه
ممنون
زمانی که رکوردی رو اضافه میکنید به DataGridView اضافه میکنید و DataSource اش یا به پایگاه داده تون؟ از این جهت می پرسم که این کد بالا مادامی که مجددا اجراش نکنید نه متوجه میشه که پایگاه داده تغییری کرده و نه جز پایگاه داده جای دیگری رو میگرده.
حالا اگر ما به DataGridView آیتمی اضافه کنیم یا به DataSource اش موردی رو اضافه کنیم بدون اینکه در پایگاه داده ثبت اش صورت بگیره، یا حتی ثبت اش کنیم ولی دوبار این کد رو اجرا نکنیم، TV1 نه متوجه تغییری میشه و نه خودش اقدامی برای بروز کردن می کنه.
Refresh کردن TV1 یعنی هر چیزی داخلش هست دوباره از نو رسم بشه، باعث نمیشه به پایگاه داده رجوع کنه، همون آیتم ها که از قبل داخلش بود رو مجددا رسم می کنه، حتی اگر در پایگاه داده کل جدول رو پاک هم بکنید این آیتم ها توی TV1 میمونن و فقط مجددا رسم میشن.
البته اگر خواستید از نو اجراش کنید اول یک ()TV1.Nodes.Clear رو هم اضافه کنید تا Node های قبلی پاک بشن.
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
زمانی که رکوردی رو اضافه میکنید به DataGridView اضافه میکنید و DataSource اش یا به پایگاه داده تون؟ از این جهت می پرسم که این کد بالا مادامی که مجددا اجراش نکنید نه متوجه میشه که پایگاه داده تغییری کرده و نه جز پایگاه داده جای دیگری رو میگرده.
حالا اگر ما به DataGridView آیتمی اضافه کنیم یا به DataSource اش موردی رو اضافه کنیم بدون اینکه در پایگاه داده ثبت اش صورت بگیره، یا حتی ثبت اش کنیم ولی دوبار این کد رو اجرا نکنیم، TV1 نه متوجه تغییری میشه و نه خودش اقدامی برای بروز کردن می کنه.
Refresh کردن TV1 یعنی هر چیزی داخلش هست دوباره از نو رسم بشه، باعث نمیشه به پایگاه داده رجوع کنه، همون آیتم ها که از قبل داخلش بود رو مجددا رسم می کنه، حتی اگر در پایگاه داده کل جدول رو پاک هم بکنید این آیتم ها توی TV1 میمونن و فقط مجددا رسم میشن.
البته اگر خواستید از نو اجراش کنید اول یک ()TV1.Nodes.Clear رو هم اضافه کنید تا Node های قبلی پاک بشن.
ابتدا ممنونم که زمان میگذارید
وقتی رکورد جدید اضافه میشه توسط کاربر اطلاعات به دیتابیس (sql server) ارسال میشه
و من بعد از نمایش پیام "اطلاعات ثبت شد" دیتاگرید رو به روز میکنم که باعث میشه بلافاصله کاربر رکوزد اضافه شده رو ببینه
اما اومدم کدهای تری ویو رو که شما زحمت کشیدید به همین قسمت هم اضافه کردم ولی متاسفانه مثل دیتا گرید رفرش نشد
اگر لازم میدونید تا تصویر هم بذارم
-
1 ضمیمه
نقل قول: کمک در مورد treeviwe
با توجه به تصویر ببینید
سطر آخر به گرید اضافه شده اما به تری ویو اضافه نشدهضمیمه 151033
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
با توجه به تصویر ببینید
سطر آخر به گرید اضافه شده اما به تری ویو اضافه نشده
ضمیمه 151033
یه سوال دیگه هم دارم
توی گرید نگاه کنید هریک از عنوان ها یک کد هم دارد
چطوری میشه توی تری ویو در کنار عناوین این کدها رو هم اضافه کرد
فیلد کدها در sql به اسم _proKey هست
-
نقل قول: کمک در مورد treeviwe
من کلا کار با تری ویو برام سخته:لبخند:
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
ابتدا ممنونم که زمان میگذارید
وقتی رکورد جدید اضافه میشه توسط کاربر اطلاعات به دیتابیس (sql server) ارسال میشه
و من بعد از نمایش پیام "اطلاعات ثبت شد" دیتاگرید رو به روز میکنم که باعث میشه بلافاصله کاربر رکوزد اضافه شده رو ببینه
اما اومدم کدهای تری ویو رو که شما زحمت کشیدید به همین قسمت هم اضافه کردم ولی متاسفانه مثل دیتا گرید رفرش نشد
اگر لازم میدونید تا تصویر هم بذارم
اول از دو مساله مطمئن بشیم. اولی اینکه جدول داخل پایگاه رو باز کنید. ببینید اون آیتم اضافه شده proParent_ اش درست ئه یا نه. اگه والد پیدا نشه TreeView نمیتونه گره ای که پدر و مادرش مفقود شده جایی نشون بده.
دوم اینکه شما آیتمی رو به DataGridView به همون روشی که اجرا می کنید اضافه کنید و برنامه رو ببندید و مجددا اجرا کنید. اگه مورد اضافه شده نه در DataGridView و نه در TreeView نمایش داده نشد، پس یک ایرادی در بروز رسانی پایگاه داده است نه TreeView.
اگر در هر دو شون به درستی نمایش داده شد، پس کد نمایش مشکلی نداره، صرفا در جایی که لازمه اجرا نشده. اگر فقط در DataGridView نمایش داده شد اونوقت بگید تا در مورد علتش بررسی کنیم.
نقل قول:
نوشته شده توسط
شهابسلطانی
یه سوال دیگه هم دارم
توی گرید نگاه کنید هریک از عنوان ها یک کد هم دارد
چطوری میشه توی تری ویو در کنار عناوین این کدها رو هم اضافه کرد
فیلد کدها در sql به اسم _proKey هست
اگه همینطوری ساده اضافه کردنش کافی باشه، اون سطری که نوشته ... var node = new رو با این دو سطر جایگزین می کنیم :
var title = reader["_proKey"].ToString() + " " + reader["_proName"].ToString().Trim();
var node = new TreeNode(title);
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
اول از دو مساله مطمئن بشیم. اولی اینکه جدول داخل پایگاه رو باز کنید. ببینید اون آیتم اضافه شده proParent_ اش درست ئه یا نه. اگه والد پیدا نشه TreeView نمیتونه گره ای که پدر و مادرش مفقود شده جایی نشون بده.
دوم اینکه شما آیتمی رو به DataGridView به همون روشی که اجرا می کنید اضافه کنید و برنامه رو ببندید و مجددا اجرا کنید. اگه مورد اضافه شده نه در DataGridView و نه در TreeView نمایش داده نشد، پس یک ایرادی در بروز رسانی پایگاه داده است نه TreeView.
اگر در هر دو شون به درستی نمایش داده شد، پس کد نمایش مشکلی نداره، صرفا در جایی که لازمه اجرا نشده. اگر فقط در DataGridView نمایش داده شد اونوقت بگید تا در مورد علتش بررسی کنیم.
اگه همینطوری ساده اضافه کردنش کافی باشه، اون سطری که نوشته ... var node = new رو با این دو سطر جایگزین می کنیم :
var title = reader["_proKey"].ToString() + " " + reader["_proName"].ToString().Trim();
var node = new TreeNode(title);
واقعا ممنونم از اینکه با صبر و حوصله جواب میدید
وقتی رکورد اضافه میشه و من فرم رو می بندم و دوباره باز میکنم
هم توی دیتا گرید هم توی تری ویو مشکل نداره و اضافه شده و نمایش داده میشه
دقیقا مشکل اینه که زمانی که فرم Active هست رفرش نمیشه
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
the king
اول از دو مساله مطمئن بشیم. اولی اینکه جدول داخل پایگاه رو باز کنید. ببینید اون آیتم اضافه شده proParent_ اش درست ئه یا نه. اگه والد پیدا نشه TreeView نمیتونه گره ای که پدر و مادرش مفقود شده جایی نشون بده.
دوم اینکه شما آیتمی رو به DataGridView به همون روشی که اجرا می کنید اضافه کنید و برنامه رو ببندید و مجددا اجرا کنید. اگه مورد اضافه شده نه در DataGridView و نه در TreeView نمایش داده نشد، پس یک ایرادی در بروز رسانی پایگاه داده است نه TreeView.
اگر در هر دو شون به درستی نمایش داده شد، پس کد نمایش مشکلی نداره، صرفا در جایی که لازمه اجرا نشده. اگر فقط در DataGridView نمایش داده شد اونوقت بگید تا در مورد علتش بررسی کنیم.
اگه همینطوری ساده اضافه کردنش کافی باشه، اون سطری که نوشته ... var node = new رو با این دو سطر جایگزین می کنیم :
var title = reader["_proKey"].ToString() + " " + reader["_proName"].ToString().Trim();
var node = new TreeNode(title);
کدها هم به عناوین اضافه شد:تشویق::تشویق::تشویق::تشوی ::تشویق::تشویق::تشویق::تشویق: :تشویق::تشویق::تشویق:
-
نقل قول: کمک در مورد treeviwe
نقل قول:
نوشته شده توسط
شهابسلطانی
واقعا ممنونم از اینکه با صبر و حوصله جواب میدید
وقتی رکورد اضافه میشه و من فرم رو می بندم و دوباره باز میکنم
هم توی دیتا گرید هم توی تری ویو مشکل نداره و اضافه شده و نمایش داده میشه
دقیقا مشکل اینه که زمانی که فرم Active هست رفرش نمیشه
همه اون کدی که برای نمایش در TreeView داریم رو داخل یک متد مثل ()private void UpdateTreeView قرار بدید و بعد وقتی پیام "اطلاعات ثبت شد" رو نشون دادید بجای Refresh اون ()UpdateTreeView رو اجرا کنید.
فقط در اولین سطر کد داخل ()UpdateTreeView نوشتن ()TV1.Nodes.Clear فراموش نشه.