PDA

View Full Version : سوال: چگونه میتوان در خواص RowHeader در یک DataGridView تغییر ایجاد کرد



ASKaffash
یک شنبه 02 تیر 1387, 17:00 عصر
سلام
دوستان چگونه میتوان مشابه ColumnHeader خواص مربوط به RowHeader را در یک DataGridView تغییر داد ؟ (مثلا در یک ردیف خاص از این سلول یک متن قرار داد)

bachebahal_1363
یک شنبه 02 تیر 1387, 17:36 عصر
می تونی از کد زیر استفاده کنی



DataGridViewCellStyle objAlignRightCellStyle = new
DataGridViewCellStyle();
objAlignRightCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
// Declare and set the alternating rows style...
DataGridViewCellStyle objAlternatingCellStyle = new
DataGridViewCellStyle();
objAlternatingCellStyle.BackColor = Color.LightGray;
YourDataGridView.AlternatingRowsDefaultCellStyle =
objAlternatingCellStyle;
// Declare and set the style for currency cells ...
DataGridViewCellStyle objCurrencyCellStyle = new
DataGridViewCellStyle();
objCurrencyCellStyle.Alignment =
DataGridViewContentAlignment.MiddleCenter;
// Change column names
YourDataGridView.Columns["Your Column's Name"].HeaderCell.Style =
objAlignRightCellStyle;
YourDataGridView.Columns["Your Column's Name"].DefaultCellStyle =
objCurrencyCellStyle;
YourDataGridView.Columns[0].HeaderText = "Your Header's Column's Name";
objCurrencyCellStyle = null;
objAlternatingCellStyle = null;
objAlignRightCellStyle = null;

ASKaffash
یک شنبه 02 تیر 1387, 17:54 عصر
سلام
دوست عزیز کجای این کد خاصیت Text یک RowHeader را عوض میکند من Cell های معمولی را نمیخواهم سلول RowHeader را میخواهم (سلول به شماره ستون 1-)
در ضمن برای سطر وستون معمولی فقط یک خط کد کافیست :


this.dataGridView1[2, 5].Value = "Ok";

bachebahal_1363
یک شنبه 02 تیر 1387, 18:07 عصر
اول اینکه ما سلول به شماره ستون 1- نداریم
از تکه کد زیر استفاده کن البته برای هر column :



YourDataGridView.Columns[0].HeaderText = "Your Header's Column's Name";

ASKaffash
یک شنبه 02 تیر 1387, 18:15 عصر
دوست من
من میدانم ستون 1- نداریم برای این گفتم که شما بدانید RowHeader از نظر مفهومی معادل ستون 1- در DataGridViwe است اگر منفی داشتیم که من سئوال مطرح نمیکردم وآن خطی که نوشتم برای ستون 1- میدادم و RowHeader را تنظیم میکردم لطفا خاصیت RowHeader را روی DataGridView مطالعه کنید

sasan9
یک شنبه 19 مرداد 1393, 18:44 عصر
سلام از این کد میتونی استفاده کنی

dataGridView1.Rows[e.RowIndex].HeaderCell.Value = "نمایش";
به جای e.RowIndex اون ردیفی که میخواییو قرار بده
موفق باشی