|
How do I achieve the DropDown drop-down style in a combobox column in a DataGridView? I can't find any setting, but I would like to, e.g. on entering invoice lines, be able to either enter a product code or select one from a list.
|
|
|
|
|
Hi,
DataGridView gives us the ComboBox column type to attach a dropdown box in a column. Below is the code snippets for the same:
BEGIN CODE
DataGridViewComboBoxColumn colGender = new
DataGridViewComboBoxColumn();
// Size the column width so it is wide enough to display the
header
colGender.AutoSizeMode =
DataGridViewAutoSizeColumnMode.ColumnHeader;
colGender.DataPropertyName = "Gender";
// Specifiy the list of choices in the combo box
colGender.Items.AddRange(new string[] { "M", "F" });
// Sort the combo box contents alphabetically
colGender.Sorted = true;
// Disable sorting for the column
colGender.SortMode = DataGridViewColumnSortMode.NotSortable;
colGender.HeaderText = "Gender";
colGender.Name = "Gender";
colGender.ReadOnly = false;
dataGridView2.Columns.Add(colGender);
//
// Column: Marital status, combo box
//
// For this column, combo box contents are retrieved from the
database
DataGridViewComboBoxColumn colMaritalStatus = new
DataGridViewComboBoxColumn();
// Size the column width so it is wide enough to display the
header
colMaritalStatus.AutoSizeMode =
DataGridViewAutoSizeColumnMode.ColumnHeader;
colMaritalStatus.DataPropertyName = "MaritalStatus";
// Retrieve the list of choices from the database
colMaritalStatus.DataSource =
dataSetAdventureWorks.Tables["MaritalStatusChoices"];
// Identify the column in the Employee table that is used to
select the combo box item
colMaritalStatus.ValueMember = "MaritalStatus";
// If the column value is not human friendly, e.g., a foreign
key identity off to a related table,
// the DisplayMember property is used to identify the column
used for display purposes
colMaritalStatus.DisplayMember = "MaritalStatus";
colMaritalStatus.HeaderText = "Marital Status";
colMaritalStatus.Name = "MaritalStatus";
colMaritalStatus.ReadOnly = false;
dataGridView2.Columns.Add(colMaritalStatus);
END CODE
Hope this helps
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi, all of you exeperts here..
I have one simple question, how to i open a windows form one project in other windows application project ??
I have 2 projects in one solution, and i added a refrence to my main windows application project, so i can see all the forms in other project.
Dim NewForm as windowsapp1.form1
NewForm = new windowsapp1.form1
NewForm.Show
Is there anyway to bypass this code, and open a form directly without declaring a new form and then open it.
Tnx in advance for your posts.
|
|
|
|
|
Please don't cross post. This is probably where this question belonged, but truth is, not many people post here. Either way, choose one forum for your post.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I did find a way to do it using system.reflection.
Private Sub OpenFormFromAssembly(ByVal FormName As String)
Dim MyAssembly As Reflection.Assembly = Reflection.Assembly.LoadFile(" Assembly to load ")
Dim MyTypes As Type() = MyAssembly.GetTypes
For Each mType As Type In MyTypes
If mType.BaseType Is GetType(Form) Then
If mType.Name = formName Then
Dim o As Object = Activator.CreateInstance(mType)
Dim f As Form = CType(o, Form)
f.Show()
End If
End If
Next
End Sub
No need to declare a new form evry time you need to open it.
Tnx for your help.
|
|
|
|
|
Hi...,
I want to write a zoom function for a PictureBox. Therefore I have to change some values (Left, Top, Width, and Height) of the PictureBox. The PictureBox is redrawn, when I just change one of theses values. So, when I change all 4 values the PictureBox gets flickering and jumping around.
How to stop/activate the Redrawing of a PictureBox.
This is my code:
private void CalcPictureBox1()
{
int zoomedWidth = (int)(bitmapDepthBuffer.Width * pBoxZoomFactor);
int zoomedHeight = (int)(bitmapDepthBuffer.Height * pBoxZoomFactor);
if (zoomedWidth > panelDepthBuffer.Width)
{
this.pBoxDepthBuffer.Left = 0;
}
else
{
this.pBoxDepthBuffer.Left = (panelDepthBuffer.Width - zoomedWidth) / 2;
}
if (zoomedHeight > panelDepthBuffer.Height)
{
this.pBoxDepthBuffer.Top = 0;
}
else
{
this.pBoxDepthBuffer.Top = (panelDepthBuffer.Height - zoomedHeight) / 2;
}
this.pBoxDepthBuffer.Width = zoomedWidth;
this.pBoxDepthBuffer.Height = zoomedHeight;
}
Thank you in advance,
Michael
modified on Friday, June 20, 2008 4:33 PM
|
|
|
|
|
To update position and size at the same time, you can use...
.SetBounds(left, top, width, height); [also: .Scale may be of use]
Hope this helps.
Matthew Butler
|
|
|
|
|
Hi Matthew,
thank you for the tip, but it didn't help, whyever. The PictureBox on the panel is still jumping around, when I change it with:
this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
...
pBoxDepthBuffer.SizeMode = PictureBoxSizeMode.Zoom;
panelDepthBuffer.Controls.Add(pBoxDepthBuffer);
panelDepthBuffer.AutoScroll = true;
...
this.pBoxDepthBuffer.SetBounds(newLeft, newTop, zoomedWidth, zoomedHeight);
I've also changed the Style of the Form with this.SetStyle to DoubleBuffering. Nothing helped.
Do you have any further ideas?
Thanks,
Michael
|
|
|
|
|
Hi...,
I have tried this rude method by setting the image first to null, changing the Bounds and initialalizing the image again:
this.pBoxDepthBuffer.Image = null;
this.pBoxDepthBuffer.SetBounds(newLeft, newTop, zoomedWidth, zoomedHeight);
this.pBoxDepthBuffer.Image = bitmapDepthBuffer;
This works now for me.
Thank you,
Michael
|
|
|
|
|
I would never bother with a picture box, I'd just draw the bitmap myself.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So, in order to allow in place editing of object properties through a Combobox, I need to implement my own Combobox. What would be the best way to do this? I'm thinking of using a TextBox and a ListBox, and letting the ListBox do most of the work. Any suggestions on other ways?
|
|
|
|
|
Why not to use a PropertyGrid?
Best regards,
Jaime.
|
|
|
|
|
Or...you could inherit from a combobox and then edit the events and properties. Then to further assist you can override the WndProc function with WinAPI commands.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Programatically converting docx to PDF without office 2007 being installed.
|
|
|
|
|
3rd party control?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
.net windows application under .net framework 3.0 or 3.5. Input is .docx file and should convert to .pdf file.
Microsoft has given SaveAsPDFandXPS.exe' word addin, this is giving SaveAs option as .pdf file.
By making use of this exe the below code is converting to PDF,
// Specifying the format in which you want the output file
object format = Word.WdSaveFormat.wdFormatPDF;
//Changing the format of the document and save them into Destination Directory
newApp.ActiveDocument.SaveAs2000(ref Target, ref format,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown,
ref Unknown, ref Unknown, ref Unknown);
// for closing the application
newApp.Quit(ref Unknown, ref Unknown, ref Unknown);
This is done by referenceing the Microsoft.Office.Interop.Word.dll. Without any reference of office dll's, is it possible to convert to PDF?
Thanks and Regards,
|
|
|
|
|
dhananjayamurthy wrote: This is done by referenceing the Microsoft.Office.Interop.Word.dll. Without any reference of office dll's, is it possible to convert to PDF?
Not of you need to reference the Microsoft.Office.Interop.Word.dll. As I said, if you don't want to install word then it will probably have to be a 3rd party control.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Excuse me for asking before exhausting all options, but I'm having a bit of a brain cramp. I would like to have a combobox bound to a list of objects, with the property Name as a DisplayMember. I now would also like the user to be able to edit the Name property directly, in the combo box. However, it doesn't look like the combobox is having any of this.
|
|
|
|
|
Brady Kelly wrote: However, it doesn't look like the combobox is having any of this.
Don't know what that means. If I understand your desired behavior the combobox should work for that.
led mike
|
|
|
|
|
I cannot access the selected item, via Items[SelectedIndex] while editing the text, as the selected index is immediately set to -1 when editing the text. My desired behaviour is to change the text in the texbox part of the Combobox, by typing different text, and have that change affected on the DisplayMember property of the currently selected object. I.e. my combo reflects a list of Section object names; I want to be able to change the name of the selected Session without using any other control.
|
|
|
|
|
Brady Kelly wrote: I cannot access the selected item, via Items[SelectedIndex] while editing the text, as the selected index is immediately set to -1
Of course it is because you don't have an item in the list selected if you typed in something new.
Brady Kelly wrote: and have that change affected on the DisplayMember property of the currently selected object.
Then you need to add the new item to your Data that is used as the DataSource and refresh the controls binding.
led mike
|
|
|
|
|
Hi!
I have a C#/.Net2.0 software, that calculates some values in thread A, which is not the thread serving the forms.
Those values should be displayed by a progressBar using a "set"-method using "Invoke".
When running the software under Vista the Bar shows the values as it should.
When running under XP the values are calculated and passed to the progressBar´s value-property, but not displayed in the form.
Is there a difference between XP and Vista that has to be taken in mind in order to make the software display the progressBar´s value?
Thanx for help!
J.
|
|
|
|
|
HI Guys,
I am trying to override the existing Save button in Word 2007.
Currently my code here doesn't seem to work, but it works when I add a new control on my command bar.
_wordApp.CommandBars["Standard"].Controls["&Save"].Visible = false;
this line doesn't work, it still appears in Word.
David.
|
|
|
|
|
i have application that works well as window app. i took some of the code to winservice it work. i now make the parameter to come from database. the service is running but does not send mail again
|
|
|
|
|
Any errors or code to support your statement?
Bob
Ashfield Consultants Ltd
|
|
|
|