|
|
Hi,
I have a datagrid bound to a previously created datatable in code and now I'm looping through the datagrid columns to change a certain column's type to a combobox, how can I do that??
Thanks guys!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
are you working with a Win control (from System.Windows.Forms) or Web (from System.Web.UI.WebControls)?
Calin
|
|
|
|
|
you may use DataGrid.Columns property to access/control the columns.
Calin
|
|
|
|
|
Ok, I found it:
private void ConvertToCombo(DataGridViewColumn tc,string[] values)
{
try
{
if (MyDataGridView.Columns.Contains(tc.Name))
{
DataGridViewComboBoxColumn cc = new DataGridViewComboBoxColumn();
cc.DataPropertyName = tc.Name;
cc.Name = tc.Name;
cc.HeaderText = tc.HeaderText;
cc.Items.AddRange(values);
MyDataGridView.Columns.Remove(tc);
MyDataGridView.Columns.Add(cc);
}
}
catch (NullReferenceException) { }
}
ConvertToCombo(MyDataGridView.Columns["GRADE"], " ;A;B;C".Split(';'));
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi All,
I'm making my first Custom Control in WPF at the moment and have created a Custom Control Library to keep them all in. As part of this first control I'm getting a lot of infrastructure set up at the same time.
Currently there are many ways to get data into the control in various formats such as single objects, lists of objects, DataTables and raw data (strings, ints etc ...) In addition to this one of the things I've included in the library is a DAL that can connect to databases to retrieve data for the controls.
Is this a good idea or not? Should I be merely allowing consumers of the library to retrieve the data externally and pump it into the controls? Or is this a nice to have that can remain a feature of the library?
Cheers,
|
|
|
|
|
Jammer wrote: Is this a good idea or not? Should I be merely allowing consumers of the library to retrieve the data externally and pump it into the controls? Or is this a nice to have that can remain a feature of the library?
That depends on your specifications. But, normally, you leave the database stuff to the consumer of the control and just support databinding to whatever source is acceptable.
|
|
|
|
|
For sure ... I think I might move this out into a general utility library.
|
|
|
|
|
Is there a way to create Comment Templates that will automatically be placed at the top of each and every newly created code file?
I'm using VS2008.
|
|
|
|
|
Tools->Options->Coding->Edit Standard Headers
you have something like that?
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
musefan wrote: Tools->Options->Coding->Edit Standard Headers
you have something like that?
No, I don't, do you?
|
|
|
|
|
Sorry i use SharpDevelop[^] and as it is very similar to VisualStudio i assumed would be similar options
I have Visual C# 2008 express edition and that does not have many options at all. Are you using an express version? maybe its a limit of that
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
No, that little option only applies to SharpDevelop.
You'd have to edit the "Item Template" files in Visual Studio to do this. I think you'd find them under "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\...".
|
|
|
|
|
|
how to set the border Line of the winForm in C#?
and set the border line color ?
Thanks !
|
|
|
|
|
do you mean the border of the whole form, or just a specific control?
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
I want to set the border of the whole form.
|
|
|
|
|
well as far as im aware there is no property for that so you will have to do it some other way, here is a couple of options:
Option 1:
Handle the paintEvent (or override OnPaint)for the form and add some code such as -
e.Graphics.DrawRectangle(...);
Be aware that controls maybe be drawn ontop of the border depending on placement
Option 2:
Create a panel, which will be your 'Main Panel' place this on the form but slightly offset its size and position so the mainForm background color can be set to the desired border color and you should only see a border effect, of course you set the 'Main Panel' backColor to be what ever you want your main backColor to be
Hope these make sense
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
Thanks musefan, I'll attempt to handle with your suggestion
|
|
|
|
|
Without adding some serious code to handle redrawing the non-client area (NOT EASY!) of the form, you can't. The window borders are drawn according to the system settings and they are for every window you see, not just yours.
|
|
|
|
|
|
Good day!
I've a question, kindly ask you to help me in this issue.
There is an multidimensional array. Like below
Column1 Column2 Column3 Column4 Column5 Column6 Column7
Row1 DATE 12/2/2009
Row2 Name Surname 01:00 02:00
Row3 LL WL SG LL WL
Row4 Jonh K 1 34 78 0,1 54
Row5 Max A 60 89 32 99 12
Note: LL,WL, SG ( Is lesson names).
How i can put this values to procedure (following format) -> BEGIN INSERT_PROC("DATE + HOUR", "NAME","SURNAME", "Lesson_Name", "Values"); END;
For / example -> BEGIN INSERT_PROC("12/2/2009 01:00AM", "Jonh", "A", "LL","1");END;
Note: The table is previewed on dataGridView.
BR
|
|
|
|
|
if you got in datagridview already then just loop through them rows and call the procedure and pass the relevant columns to it
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
for (int m = 2; m < 8; m++) (There is only 01:00 and 02:00 hours, each of them consist 3 lessons)
{
for (int i = 3; i < 17; i++) (There is 17 students)
{
for(int j=2;j<8;j++){
switch (dataGridView1.Rows[2].Cells[m].Value.ToString())
{
case "Liquid Level":
for (int n = 2; n < 8; n++)
{
switch (dataGridView1.Rows[1].Cells[n].Value.ToString())
{
case "01:00":
formattedValue = dtPicker.Value.AddHours(3).ToString("yyyyMMdd HH:mm:ss");
date_stamp = formattedValue;
name = dataGridView1.Rows[i].Cells[0].Value.ToString();
surname = dataGridView1.Rows[i].Cells[1].Value.ToString();
lesson = "LL";
mark = dataGridView1.Rows[i].Cells[j].Value.ToString();
OracleCommand cmd = new OracleCommand("begin CPF_TANK_DATA_INSERT('" +
date_stamp + "','" + name + "','" +
surname + "','+lesson+','" +
mark + "'); END;", conn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery()
case "02:00:
.....
....
}
}
}
}
But it gives an errors. Or puts more values. Where is mistakes?
|
|
|
|
|
sorry to say but that is very messy code, does your datagridview already contain the data exactly how you want it to be put in your database? you might want to look into using structs to store lesson info and student info too, that may help with things
If you have errors please post the error messages...
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|