|
hi all,
pls somebody help me to load two combobox side by side on clicking a button(single click).i will attach my code.my code is building but i get the output with only one loaded combobox.another one remains empty
MY CODE:
DataTable table = new DataTable();
table.Columns.Add("SS");
DataRow row;
for (int i = 0; i < 10; i++)
{
row = table.NewRow();
row["SS"] = i + 1;
table.Rows.Add(row);
}
comboBox1.DataSource = table;
comboBox1.DisplayMember = "SS";
DataTable s = new DataTable();
s=table.Clone();
table.Columns.Add("SS1");
DataRow row1;
for (int j = 0; j < 10; j++)
{
row1 = table.NewRow();
row1["SS1"] = j + 1;
table.Rows.Add(row1);
}
comboBox2.DataSource = table;
comboBox2.DisplayMember = "SS1";
thank you,
saravana.
|
|
|
|
|
sowmyasaravanakumar wrote: another one remains empty
No. Just scroll down the comboBox2. You will see the new row that you just added..
Because of this line table.NewRow(); , new row will be appended to table1. So, first 10 rows of column "SS1" of table1 will be blank.
|
|
|
|
|
If you don't want to append new rows to table1 and you just want add one more column called SS1 and add the value then you may try the code below..
<br />
DataTable table = new DataTable();<br />
<br />
table.Columns.Add("SS");<br />
<br />
DataRow row;<br />
<br />
for (int i = 0; i < 10; i++)<br />
{<br />
row = table.NewRow();<br />
row["SS"] = i + 1;<br />
<br />
table.Rows.Add(row);<br />
}<br />
comboBox1.DataSource = table;<br />
comboBox1.DisplayMember = "SS";<br />
<br />
DataTable s = new DataTable();<br />
s = table.Clone();<br />
<br />
table.Columns.Add("SS1");<br />
int j = new int();<br />
foreach (DataRow dr in table.Rows)<br />
{<br />
dr["SS1"] = j++;<br />
}<br />
<br />
comboBox2.DataSource = table;<br />
comboBox2.DisplayMember = "SS1";
Hope it would help..
|
|
|
|
|
Hi all,
I'm trying to manipulate menuitems of a MdiParent from MdiChild, here's the code that i have
frmMain <- the MdiParent Form
private void Main_Load(object sender, System.EventArgs e)
{
frmsignon fs = new frmsignon();
fs.MdiParent = this;
fs.Show();
}
i'm trying the below code from my MdiChild form to manipulate the menus on my MdiParent form
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = new frmMain();
fM.menuItem1.Enabled = false;
}
this code has no build errors, but it has no effect upon run time, the menuItem1 of my MdiParent form is still ENABLED.
What seems to be missing? Please help me make this work. Thanks in advance
-::maximus::-
|
|
|
|
|
use this.Parent
Form2 fr2 = (Form2)this.Parent;
and make menuItem1 public
but better approach is to make function in MDI parent to enable and disable menu item and call function in child using fr2.
|
|
|
|
|
Thanks ashuka
you mean changing the
frmMain fM = new frmMain();
to
Form2 fr2 = (Form2)this.Parent; ?
menuItem1 is already public.
-::maximus::-
|
|
|
|
|
yeah dear
Ashu
Ashish Kasama
|
|
|
|
|
Hmmm...
Im getting this error:
An unhandled exception of type 'System.InvalidCastException' occurred
Additional information: Specified cast is not valid.
my code on the MDIChild form looks like this now
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = (frmMain)this.Parent;
fM.menuItem1.Enabled = false;
}
-::maximus::-
|
|
|
|
|
where you launch it
frmSignOn frm = new frmSignOn();
frm. MdiParent = this;
frm.Show();
and at the time of
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = (frmMain)this.MdiParent;
fM.menuItem1.Enabled = false;
}
|
|
|
|
|
Thanks much! it really worked!
got what went wrong
private void frmSignOn_Load(object sender, System.EventArgs e)
{
frmMain fM = (frmMain)this.Parent;
frmMain fM = (frmMain)this.MdiParent;
fM.menuItem1.Enabled = false;
}
Thanks Ashu
Regards
-::maximus::-
|
|
|
|
|
you are welcome
|
|
|
|
|
hello ,
i want to export data from datagrid to excel sheet iam getting one error,
error:
Control 'DataGrid1__ctl3__ctl0' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server.
iam getting error at this line
DataGrid1.RenderControl(htmlWrite);
please give me any advice
srinivas
|
|
|
|
|
Hi,
Hope this code help
private void button1_Click(object sender, System.EventArgs e)
{
SaveFileDialog SD= new SaveFileDialog();
SD.Filter = "csv|*.csv|Comma Seperated Files|*.csv|All Files|*.*";
SD.InitialDirectory = @"C:\";
if (SD.ShowDialog() == DialogResult.OK)
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(SD.FileName))
{
int Colcnt = dsResults.Tables["tbl_Master_Pol_Lst"].Columns.Count;
int Rowcnt = dsResults.Tables ["tbl_Master_Pol_Lst"].Rows.Count;
for(int x=0;x<=(Colcnt-1);x++)
{
writer.Write(dsResults.Tables["tbl_Master_Pol_Lst"].Columns[x].ColumnName.Trim()+ ",");
}
writer.WriteLine();
for(int x=0;x<=(Rowcnt-1);x++)
{
for(int y=0;y<=(Colcnt-1);y++)
{
if (y == 2)
{
writer.Write("'" + dsResults.Tables["tbl_Master_Pol_Lst"].Rows[x].ItemArray.GetValue(y)+ ",");
}
else
{
String varData = Convert.ToString(dsResults.Tables["tbl_Master_Pol_Lst"].Rows[x].ItemArray.GetValue(y));
writer.Write(varData.Replace(","," ")+ ",");
}
}
writer.WriteLine();
}
writer.Flush();
MessageBox.Show(SD.FileName + " successfully created");
}
}
-::maximus::-
|
|
|
|
|
Thankyou zenithmaximus,
iam getting at savedialoguebox(SD)
iam using datagrid and also iam using paging for datagrid.
srinivas
|
|
|
|
|
Thankyou zenithmaximus,
iam getting at savedialoguebox(SD) <- you mean getting confused?
iam using datagrid and also iam using paging for datagrid.
the save dialogue statements is where you specify the path of where you're saving the data from your datagrid to a CSV file. The code applies to a scenario where you're saving your exported data from datagrid to a CSV(excel like) file, from clicking a botton.
-::maximus::-
|
|
|
|
|
iam getting error near save dialogue box C:\Inetpub\wwwroot\UserManagement\userdetails1.aspx.cs(170): The type or namespace name 'SaveFileDialog' could not be found (are you missing a using directive or an assembly reference?)
srinivas
|
|
|
|
|
Hi All,
I am new to C#. I have created a Windows Application and included a User Control in it. Now i want to use the User Control in my Form at Design Time. What is the procedure?
Thanks in advance.
|
|
|
|
|
Hello,
After you compiled it, you should see the UserControls in the Toolbox but not in the Standard Forms Controls.
There is a seperate region for your controls.
All the best,
Martin
|
|
|
|
|
I am unable to locate it. Could you help me out.
|
|
|
|
|
DumbDude.Dll wrote: I am unable to locate it.
Do you mean the Toolbox?
Ctrl+Alt+X
All the best,
Martin
|
|
|
|
|
I am sorry. I am unable to find User Control on Toolbox.
|
|
|
|
|
If you see your From in the design view (not in code view), and you look at the Toolbox in the Region UserControls.
If this is empty you can rightmouseclick at the toolbox and select "Add/Remove elements".
Then you search for your "exe" file under ..\bin\debug and doubleclick it .
The List should then contain your controls.
All the best,
Martin
|
|
|
|
|
Thank you very much Martin.
It works.
Thanks once again.
|
|
|
|
|
You are very much wellcome!
P.S.: There is a VisualStudio Forum[^] here on CP, for questions like this.
All the best,
Martin
|
|
|
|
|
Hello friends,
I want to turn off AGC (Automatic Gain Control) in WinXP and
Windows Vista also. How to do that.
Thanks in Advance.
Rahul Kulkarni
|
|
|
|